| 04-22-2006, 05:37 PM | #1 |
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: JASS:X = 100.0 * Cos( GetUnitFacing(target) ) Y = 100.0 * Sin( GetUnitFacing(target) ) Help plz :x |
| 04-22-2006, 05:48 PM | #2 |
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 |
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 |
And to convert the angle returned by GetUnitFacing to radians instead of degrees. |
| 04-22-2006, 06:05 PM | #5 | |
Quote:
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 |
Yes, you must give Cos and Sin radians if it is supposed to work correctly. |
| 04-22-2006, 06:40 PM | #7 | |
Quote:
|
| 04-22-2006, 08:34 PM | #8 | |
Quote:
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 ^^. |
