1
2
Aug 15 2008, 10:47 pm
In response to Jtgibson
|
|
Well, an extra if() or ? operator can fix this. <_<
|
Guys, you're confusing him. >.>
Jeff, I advise you to just go with the flow. Stick with the standard method. It's not necessary to make simple things a little bit more complicated. In mathematics, angles are measured counter-clockwise with respect to the positive x-axis. A whole revolution is equal to 360 degrees. You can divide vector v into it's x and y components. vx = v*cos(angle) vy = v*sin(angle) //angles are in degrees So.. Telling your mob to move 10 steps due 30 degrees with respect to the positive x-axis is just like telling him to move 10*cos(30) x-steps and 10*sin(30) y-steps. Remember that: * v2 = vx2 + vy2 //Pythagorean theorem * Negative angles are measured clockwise. |
In response to Jtgibson
|
|
-30 (0 - 30) should be the same as 360 - 30, which is 330.
So what you're saying is that's not right? |
In response to CaptFalcon33035
|
|
abs(-30 % 360) doesn't equal 330, though. It equals 30.
|
In response to Jemai1
|
|
Thanks for the good explanation. I just ignored everyone's post after JTGibson's >_<
|
In response to Jtgibson
|
|
No. Tangent is equal to opposite over adjacent.
So, for lines.. angle = arctan(Δy/Δx) or angle = arctan(slope) Remember: That's for lines; not for rays. - The reason why I use the same as Lummox JR's method. |
In response to Jemai1
|
|
Right, right. I had it backwards. The basic concept applies, and both the arctan() and the library have it fine.
|
1
2