+Dick Montage Subscriber² Posted February 27, 2009 Subscriber² Share Posted February 27, 2009 I'm writing a speedometer app for my WinMo phone. And am stuck on one maths part. Let's say the form is 300*300. I have drawn a circle of the same size. The centre point is 150*150. My line is 150px long, starting at my centre point. How do I work out the coordinates of the end point of the line, if I know: Coordinates of the start The angle The length Any help appreciated. Link to comment Share on other sites More sharing options...
0 Doli Posted February 27, 2009 Share Posted February 27, 2009 Look into Polor coordinate system http://en.wikipedia.org/wiki/Polar_coordinates at "Converting between polar and Cartesian coordinates" That should help. I would help more but I have to go and fight traffic to get to class (I need to stay off neowin before class). Link to comment Share on other sites More sharing options...
0 mail Posted February 27, 2009 Share Posted February 27, 2009 It's pretty much this: r = radius ( 150 in this case ) Link to comment Share on other sites More sharing options...
0 Dance. Posted February 27, 2009 Share Posted February 27, 2009 I don't get what you're saying. So far you're saying that there is a square of 300 x 300 units. In this square is a circle which is enclosed with a radius of 150 units. Your center point is the center of the circle. Now you've got another radius with an angle of 'x' and you want to find the length of what? My understanding Alpha (the funny proportionality sign) is the unknown angle. Anyway, could I get a diagrammatic representation if it isn't too difficult? And also can you tell me if this line from the centre ends on the circumference of the circle or the perimeter of the square? Link to comment Share on other sites More sharing options...
0 mail Posted February 27, 2009 Share Posted February 27, 2009 He is making a speedometre so I'm guessing he has to move the radius line to a certain coordinate with one fixed at (0 0) and the angle will represent the speed. Link to comment Share on other sites More sharing options...
0 ViZioN Posted February 27, 2009 Share Posted February 27, 2009 Doli and mail have it spot on, you're just converting a length + angle into an x,y length, which you can then work out the new coordinate from. Link to comment Share on other sites More sharing options...
0 Bookieass Posted February 27, 2009 Share Posted February 27, 2009 I don't get what you're saying. So far you're saying that there is a square of 300 x 300 units. In this square is a circle which is enclosed with a radius of 150 units. Your center point is the center of the circle. Now you've got another radius with an angle of 'x' and you want to find the length of what?My understanding Alpha (the funny proportionality sign) is the unknown angle. Anyway, could I get a diagrammatic representation if it isn't too difficult? And also can you tell me if this line from the centre ends on the circumference of the circle or the perimeter of the square? According to the diagram..... radius of the circle is "r" so, diagonal of the square from the centre of circle would be some like that (diagonal)^2 = r^2 + r^2 in other words diagonal^2 = 2*(r^2) so length of diagonal is square root of (2r).... ie its total length of the angled segment and length of seg (that starts from the circumference of the circle towards the squared cornered) = length(diagonal) - radius of circle Hope that helps Link to comment Share on other sites More sharing options...
0 noroom Posted February 27, 2009 Share Posted February 27, 2009 The hint in mail's post answers the question. Let's call the angle a and the length r. The coordinates of the center point (p1) are (x1=150, y1=150). The coordinates of p2 = (x2, y2) given in relation to p1: x2 = r * sin(a) * -1 y2 = r * cos(a) The -1 in x2 is needed because when drawing on forms, point (0, 0) is at the top left, instead of bottom left. So it comes to: x2 = 150 + r * sin(a) * -1 y2 = 150 + r * cos(a) Just be careful with the sin and cos functions, depending on your programming language of choice they might take radians instead of degrees. To convert between those just use (pi/180) (or (180/pi)) as a factor. Link to comment Share on other sites More sharing options...
Question
+Dick Montage Subscriber²
I'm writing a speedometer app for my WinMo phone. And am stuck on one maths part.
Let's say the form is 300*300. I have drawn a circle of the same size. The centre point is 150*150.
My line is 150px long, starting at my centre point.
How do I work out the coordinates of the end point of the line, if I know:
Coordinates of the start
The angle
The length
Any help appreciated.
Link to comment
Share on other sites
7 answers to this question
Recommended Posts