amitsarangi / mt4j

Automatically exported from code.google.com/p/mt4j
GNU General Public License v2.0
0 stars 0 forks source link

heading2D() for Vector3D class to get the angle of rotation from the vector #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In the Nature of code Vector3D Class from daniel Shiffman is a useful method.
http://www.shiffman.net/itp/classes/nature/library/noc/Vector3D.html#heading2D()

 public float heading2D() {
        float angle = (float) Math.atan2(-this.y, this.x);
        return -1*angle;
    }

Original issue reported on code.google.com by stefan.s...@googlemail.com on 5 Apr 2010 at 7:28

GoogleCodeExporter commented 9 years ago
Hm, Im not even sure what this exactly does. The angle between what?

Original comment by sirhc.f...@gmail.com on 6 Apr 2010 at 12:30

GoogleCodeExporter commented 9 years ago
This gives you the angle of the vector in reference to the screen, (it's from a
flocking code i came across, so it's for getting the rotation angle of a boid 
from
the current movement vector to rotate the visual representation of it according 
to
the movement.)

Original comment by stefan.s...@googlemail.com on 6 Apr 2010 at 4:40