VectorMath Class

Class org.rapo.games.VectorMath

Inheritance > VectorMath

A utility class containing static methods useful for manipulating vectors. Vectors are implemented as Objects with "x" and "y" properties. Bounds are implemented as Objects with "xMin", "xMax", "yMin" and "yMax" properties. Bounds are essentially 4D vectors.
Method Summary
 static Void 
 addVectors(v1:Object, v2:Object)
Adds two vectors and stores the results in v1.
 static Void 
 copyBounds(b1:Object, b2:Object)
Copies the properties of one Bounds instance to another.
 static Void 
 copyVector(v1:Object, v2:Object)
Copies the "x" and "y" properties of one vector Object to another.
 static Number 
 getDistance(v1:Object, v2:Object)
Returns the distance between two vectors.
 static Number 
 getMagnitude(vector:Object)
Returns the magnitude of a vector.
 static Boolean 
 inBounds(vector:Object, bounds:Object)
Returns a Boolean indicating whether or not a coordinate (vector) is inside a given Bounds (rectangle).
 static Void 
 insetBounds(bounds:Object, xinset:Number, yinset:Number)
Insets the given Bounds' rectangle by the specified x and y amounts.
 static Void 
 multVectors(v1:Object, v2:Object)
Multiplies two vectors and stores the results in v1.
 static Object 
 newBounds(xMin:Number, xMax:Number, yMin:Number, yMax:Number)
Returns a new Bounds instance.
 static Object 
 newVector(x:Number, y:Number)
Creates a new Object and sets its "x" and "y" properties.
 static Void 
 normalizeVector(vector:Object)
Normalizes a vector.
 static Void 
 scaleVector(vector:Object, scalar:Number)
Multiplies the coordidnates of a vector by a scalar value
 static Void 
 setVector(vector:Object, x:Number, y:Number)
Sets the "x" and "y" properties of a vector Object.
 static Void 
 subtractVectors(v1:Object, v2:Object)
Subtracts two vectors and stores the results in v1.
Method Detail
addVectors
public static function addVectors(v1:Object, v2:Object):Void
Adds two vectors and stores the results in v1.
Parameters:
v1
Vector 1 - contains the result.
v2
Vector 2.
copyBounds
public static function copyBounds(b1:Object, b2:Object):Void
Copies the properties of one Bounds instance to another.
Parameters:
b1
Bounds 1 - Receives the new bounds properties.
b2
Bounds 2
copyVector
public static function copyVector(v1:Object, v2:Object):Void
Copies the "x" and "y" properties of one vector Object to another.
Parameters:
v1
The vector Object which receives the coordiantes of v2.
v2
The vector Object containing the coordinates are copied to v1.
getDistance
public static function getDistance(v1:Object, v2:Object):Number
Returns the distance between two vectors.
Parameters:
v1
Vector 1.
v2
Vector 2.
getMagnitude
public static function getMagnitude(vector:Object):Number
Returns the magnitude of a vector.
Parameters:
vector
Vector.
inBounds
public static function inBounds(vector:Object, bounds:Object):Boolean
Returns a Boolean indicating whether or not a coordinate (vector) is inside a given Bounds (rectangle).
Parameters:
vector
Coordinates
bounds
Bounds (bounding rectangle)
insetBounds
public static function insetBounds(bounds:Object, xinset:Number, yinset:Number):Void
Insets the given Bounds' rectangle by the specified x and y amounts.
Parameters:
bounds
Bounds instance.
xinset
Amount to inset the left and right.
yinset
Amount to inset the top and bottom.
multVectors
public static function multVectors(v1:Object, v2:Object):Void
Multiplies two vectors and stores the results in v1.
Parameters:
v1
Vector 1 - contains the result.
v2
Vector 2.
newBounds
public static function newBounds(xMin:Number, xMax:Number, yMin:Number, yMax:Number):Object
Returns a new Bounds instance.
Parameters:
xMin
The rectangle's top
xMax
The rectangle's right
yMin
The rectangle's bottom
yMax
The rectangle's left
newVector
public static function newVector(x:Number, y:Number):Object
Creates a new Object and sets its "x" and "y" properties.
Parameters:
x
The new vector's x coordinate.
x
The new vector's y coordinate.
normalizeVector
public static function normalizeVector(vector:Object):Void
Normalizes a vector. (Divides its coordinates by its magnitude)
Parameters:
vector
Vector.
scaleVector
public static function scaleVector(vector:Object, scalar:Number):Void
Multiplies the coordidnates of a vector by a scalar value
Parameters:
vector
The vector being scaled.
scalar
The scale value.
setVector
public static function setVector(vector:Object, x:Number, y:Number):Void
Sets the "x" and "y" properties of a vector Object.
Parameters:
x
The new x coordinate.
x
The new y coordinate.
subtractVectors
public static function subtractVectors(v1:Object, v2:Object):Void
Subtracts two vectors and stores the results in v1.
Parameters:
v1
Vector 1 - contains the result.
v2
Vector 2.



Documentation generated by BLDoc Community Edition from B-Line Express.