I need some help coming up with a formula that:
Will set an x postion according to an angle so say
Angle=50,90 and 40. The sprite is at the 50 angle, or at the top. I can get the y postion. Anyway to tell where it needs to be so it always goes to the right x postion?
Sprite 1
:
: :
:50:
: :
Unkown : : Y of (sprite 1) - Y of (Sprite 2)
: :
: :
:40 90:
*****************
X(Also Unknown)
What I basically want is a formula that positions sprite one so it is always at this ratio thingy from sprite one.
Offline
The tangent of the 40 degree angle is the ratio of the perpendicular sides of the right triangle so
[(Y of Sprite 1) - (Y of Sprite 2)]
tangent 40 = --------------------------------------------
[(X of Sprite 1) - (X of Sprite 2)]
So, you can then solve for what you want
X of Sprite 1 = (X of Sprite 2) + [(Y of Sprite 1) - (Y of Sprite 2)} / tangent 40
Note: Because Scratch uses an odd definition of zero degrees (straight up) which differs from the usual math book definition (zero degrees is off to the right), I might have screwed this up a little...if it doesn't work, try switching the roles of X and Y. Sorry I can't do any better right now, gotta run!
Offline
Thanks Man! That is exactly what I was looking for and it works pretty well. One question though. When did you join the scratch team?
Offline
TheSaint wrote:
Thanks Man! That is exactly what I was looking for and it works pretty well. One question though. When did you join the scratch team?
Well, look at that! I wasn't aware that I had joined the team. Thanks for pointing it out. I'm not sure why my title is showing up that way...
Offline