tototototototot

All posts in Math

Find the shortest rotation angle between two angles

That’s it, the following code finds for you the shortest rotation angle from a given angle to another: [sourcecode language=’as3′] var diffAngle:Number = Math.atan2(Math.sin(angleTo – currentAngle), Math.cos(angleTo – currentAngle)); [/sourcecode] The code was given on this forum. You’ll also find a way to do it with vectors.

Calculate the surface/area of an irregular polygon

There are many ways to calculate the surface of a polygon. It all depends on what kind of data you have to deal with. If you have only vertices (points) or if you have the segments associated to them as well. The most evident solution would be to divide the polygon in triangles and calculate […]

Get the rotation angle in degree from a direction

[sourcecode language=’cpp’]var dx:Number = x1 – x2; var dy:Number = y1 – y2; rotation = Math.atan2( dy , dx ) * ( 180 / 3.141592653589793 ) ;[/sourcecode]