Trigonometry with pic.rotate help
Author |
Message |
david92ng
|
Posted: Sat May 10, 2008 8:17 pm Post subject: Trigonometry with pic.rotate help |
|
|
we have one point (x,y) and we have an other point(x2,y2)
x,y is the center.
lets say x2 and y2 is some random point around the center.
now the question, i want to draw a picture at the center(x,y) and after i will use pic.rotate it so it will point to x2,y2.
To do that i somehow need the angle from the center to the other point.
i totally forgot Trigonometry which i know i need to use for this. can someone give me the formula?
thanks |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
CodeMonkey2000
|
Posted: Sat May 10, 2008 9:49 pm Post subject: Re: Trigonometry with pic.rotate help |
|
|
Merry Christmas!
Turing: |
fcn getAngle (x1, y1, x2, y2 : real) : real
/*Some code shamelessly stolen from Bored*/
var opp := y2 - y1
var adj := x2 - x1
if adj = 0 then
if y2 > y1 then
result 90
else
result 270
end if
elsif opp >= 0 and adj > 0 then
result arctand (opp / adj )
elsif adj < 0 then
result 180 + arctand (opp / adj )
elsif opp < 0 and adj > 0 then
result 360 + arctand (opp / adj )
end if
end getAngle
|
Just pass in the coordinates of your two points. |
|
|
|
|
 |
david92ng
|
Posted: Sat May 10, 2008 10:50 pm Post subject: Re: Trigonometry with pic.rotate help |
|
|
thanks. works great. |
|
|
|
|
 |
|
|