Calculate third point from 2 points and an angle

Calculate third point from 2 points and an angle

Postby GameVSL » Wed Feb 28, 2018 10:32 am


I'm having a hard time putting together a formula. I have 2 points (x0, y0) and (x1, y1) and an angle (k).
Using this information I need to calculate a third point that is k degrees from the previous 2 points.
The problem is something like this:
problema_code.jpg
problema_code.jpg (51.77 KiB) Viewed 290 times

Is it possible to do that? Thank you for your attention.
GameVSL
 
Posts: 1
Joined: Wed Feb 28, 2018 9:09 am
Reputation: 0

Re: Calculate third point from 2 points and an angle

Postby rmiller2015 » Mon Apr 02, 2018 10:08 pm

Yes, it is possible.

Assuming the vector length is the same, you could define the first point as the origin (0,0).
Then describe the first vector in polar coordinates, (r, [tex]\theta[/tex]), where [tex]r = \sqrt{x_{1 }^{2} + y_{1 }^{2}}[/tex] and [tex]\theta[/tex] = [tex]arctan(y_{1 }/x_{1 })[/tex].

Then create the second vector by adding k degrees to [tex]\theta[/tex]: [tex]\theta_{2 }[/tex] = [tex]\theta[/tex] + k
Then convert from polar coordinates back to rectangular coordinates--if you need them that way:

[tex]x_{2 } = r cos(\theta_{2 })[/tex] and
[tex]y_{2 } = r sin(\theta_{2 })[/tex]

rmiller2015
 
Posts: 6
Joined: Mon Aug 31, 2015 5:57 pm
Reputation: 1


Return to Programming and Algorithms



Who is online

Users browsing this forum: No registered users and 1 guest