Packagecv.util
Classpublic class GeomUtil

A collection of useful geometry related functions. Some are actually replacements for built in Math class methods becuase they are more effecient than the default.



Public Methods
 MethodDefined by
  
getAngle(point1:Point, point2:Point):Number
[static] Gets the angle of the target point based on the given differences in distance.
GeomUtil
  
getDistance(x1:Number, x2:Number, y1:Number, y2:Number):Object
[static] Used to determine the distance between two points.
GeomUtil
  
getDistance3D(x1:Number, x2:Number, y1:Number, y2:Number, z1:Number, z2:Number):Number
[static] Used to determine the distance between two 3D points.
GeomUtil
  
rotateCoord(x:Number, y:Number, sin:Number, cos:Number, reverse:Boolean):Point
[static] Takes a given coordinate and rotates it in a 2D space.
GeomUtil
  
rotatePoint(point:Point, centerPoint:Point, angle:Number):void
[static] Rotates a Point around another Point by the specified angle.
GeomUtil
  
turnToPath(point:Point):Number
[static] Returns the degree to rotate to point in that direction.
GeomUtil
Method detail
getAngle()method
public static function getAngle(point1:Point, point2:Point):Number

Gets the angle of the target point based on the given differences in distance.

Parameters
point1:Point — The first point
 
point2:Point — The second point to base the angle on

Returns
Number — The angle between the two points in radians
getDistance()method 
public static function getDistance(x1:Number, x2:Number, y1:Number, y2:Number):Object

Used to determine the distance between two points.

Parameters
x1:Number — The x of point 1
 
x2:Number — The x of point 2
 
y1:Number — The y of point 1
 
y2:Number — The y of point 2

Returns
Object — An object with the difference between the x coordinates, dx. The difference between the y coordinates, dy. The actual distance, dist, and the distance squared, distSQ.
getDistance3D()method 
public static function getDistance3D(x1:Number, x2:Number, y1:Number, y2:Number, z1:Number, z2:Number):Number

Used to determine the distance between two 3D points.

Parameters
x1:Number — The x of point 1
 
x2:Number — The x of point 2
 
y1:Number — The y of point 1
 
y2:Number — The y of point 2
 
z1:Number — The z of point 1
 
z2:Number — The z of point 2

Returns
Number — The distance between the two points.
rotateCoord()method 
public static function rotateCoord(x:Number, y:Number, sin:Number, cos:Number, reverse:Boolean):Point

Takes a given coordinate and rotates it in a 2D space. This is used for calculations like collosions detection.

Parameters
x:Number — The x coordinate
 
y:Number — The y coordinate
 
sin:Number — The sine of the angle to rotate
 
cos:Number — The cosine of the angle to rotate
 
reverse:Boolean — Which direction to rotate

Returns
Point — The adjusted point after rotation.

See also

rotatePoint()method 
public static function rotatePoint(point:Point, centerPoint:Point, angle:Number):void

Rotates a Point around another Point by the specified angle.

Parameters
point:Point — The Point to rotate.
 
centerPoint:Point — The Point to rotate this Point around.
 
angle:Number — The angle (in degrees) to rotate this point.
turnToPath()method 
public static function turnToPath(point:Point):Number

Returns the degree to rotate to point in that direction. This assumes you are at point 0,0.

Parameters
point:Point — The target x velocity.

Returns
Number — The degrees to rotate

See also