HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Math Question - Rotation

05-09-2008, 11:52 PM#1
TheSecretArts
I'm am trying to get a Vector (facing point A) to pivot to face a point B.
Say I have magnitude L, angle of change Theta.
Would I do
sin(Theta)*L = New Bx Coord
sin(90-Theta)*L = New By Coord

I tested this under two situations (45 degree turn and -22.5 degree turn) and it worked but I'm not sure if its the right method
Heres an image to clarify.

ofc it cannot go farther than a 90 degree turn in one step, but why would you?
Attached Images
File type: jpgMath.jpg (12.1 KB)
05-10-2008, 03:11 AM#2
grim001
Formula for XY rotation:

NewX = Cos(theta)*x + Sin(theta)*y
NewY = Cos(theta)*y - Sin(theta)*x

Works with any number of degrees.
05-10-2008, 03:16 AM#3
Castlemaster
The only foreseeable problem is like you said: rotating >90 degrees. I'm not sure what you're using this for, but I have made a spell where I made a unit rapidly rotate as much as 180 degrees.

Just a note about unitfacing, if you make a trigger that relies on the unit's facing angle, it takes the unit a second or so to actually face that way. So if you want the unit to switch directions and immediately do something, use the new angle instead of GetUnitFacing()
05-10-2008, 04:34 PM#4
TheSecretArts
thanks grim! +rep
Im not sure why my way was working but whatever.