HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Quick Trig Question

04-22-2006, 05:37 PM#1
mmx2000
It's been a long time since using trig.... so this is giving me a bit of trouble, heh.
I want to create something 100.0 distance in front of a unit (as in, straight in front of the unit's face, whatever facing angle that may be).
To get the (X,Y) of the new position, I thought it was:
Collapse JASS:
X = 100.0 * Cos( GetUnitFacing(target) )
Y = 100.0 * Sin( GetUnitFacing(target) )
But erm, this isn't working.
Help plz :x
04-22-2006, 05:48 PM#2
Blade.dk
Collapse JASS:
   set x = GetUnitX(target)+100*Cos(GetUnitFacing(target)*bj_DEGTORAD)
   set y = GetUnitY(target)+100*Sin(GetUnitFacing(target)*bj_DEGTORAD)
04-22-2006, 06:03 PM#3
blu_da_noob
Just to explain Blade's post a little: You need to take the X and Y you are projecting from (in your case, the X and Y of your unit) and add those values to them.
04-22-2006, 06:04 PM#4
Blade.dk
And to convert the angle returned by GetUnitFacing to radians instead of degrees.
04-22-2006, 06:05 PM#5
mmx2000
Quote:
Originally Posted by blu_da_noob
Just to explain Blade's post a little: You need to take the X and Y you are projecting from (in your case, the X and Y of your unit) and add those values to them.
What a stupid mistake.
Also, did not know about bj_DEGTORAD. I take it that Cos() and Sin() must use radians rather than degrees?
EDIT: You post fast ^^

Thanks guys.
04-22-2006, 06:06 PM#6
Blade.dk
Yes, you must give Cos and Sin radians if it is supposed to work correctly.
04-22-2006, 06:40 PM#7
mmx2000
Quote:
Originally Posted by Blade.dk
Yes, you must give Cos and Sin radians if it is supposed to work correctly.
Do all natives that deal with angles require radians? Or is it only the trig functions?
04-22-2006, 08:34 PM#8
TaintedReality
Quote:
Do all natives that deal with angles require radians? Or is it only the trig functions?

Many do, I think there's some that don't. If you look at the native the parameter is either 'degrees', or 'radians'.

native SetCameraRotateMode (real x, real y, real radiansToSweep, real duration) returns nothing

native Sin (real radians) returns real

You get my point =P.

Edit: And yes, I would have used JASS tags but bold doesn't work inside of em ^^.