• 0

[Maths] Coordinates - Line Drawing - Angles


Question

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

  • 0

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

waat.jpg

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

  • 0
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

waat.jpg

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.