A class which serves as the base for many of the engine's calculations.
In it's core, a Vector is simply used to store two values: x and y.
But the Vector class also supplies many methods for vector operations
as well as static helper methods
public var x:Number
public var y:Number
public function Vector(cX:Number, cY:Number)
Parameters
public function add(v:Vector):Vector
Vector addition.
Parameters
| v:Vector — The vector who's x and y values will be added to this vector's x and y values.
|
Returns
public function angleTo(v:Vector):Number
Calculates the angle between this vector to another
Parameters
Returns
public function clone():Vector
Returns a copy of the vector.
This is very usefull when you don't want to change the current vector, and can be used in combination with any other operation like normalize(), add(), or multiply().
Returns
public function distanceSquaredTo(v:Vector):Number
Calculates the distance squared between this vector to another
Parameters
Returns
public function distanceTo(v:Vector):Number
Calculates the distance between this vector to another
Parameters
Returns
public function divide(n:Number):Vector
Divides both the x and y values by the given number. Division by 0 is ignored.
This is usefull for scaling the vector without altering it's direction.
Parameters
Returns
public function dot(v:Vector):Number
Dot product.
Parameters
Returns
public function getAngle():Number
The angle of the vector in degrees.
Returns
public function getMagnitude():Number
Returns the magnitude, or length, of the vector.
Returns
public function getMagnitudeSquared():Number
Returns the magnitude, or length, of the vector multiplied by itself.
This is more efficient than getMagnitude, as no sqrt() operation is needed, and should be used in cases where the magnitude squared is needed.
Returns
public function getNormal(cD:Number = 1):Vector
Returns the vector's right-hand normal
Parameters
Returns
public function minus(n:Number):Vector
Subtracts a scalar from both the x and y components.
Parameters
Returns
public function normalize(len:Number = 1):Vector
Normalizes the vector to unit length.
In other words, it modifies the vector's x and y values so that the vector's magnitude is one but it's angle is unchanged.
Parameters
| len:Number (default = 1 ) — specify this value if you would like the vector's magnitude to be a value other than one.
A negative value would simply reverse the vector.
|
Returns
public function perp(v:Vector):Number
Perpendicular product.
This is the same as using dot() with v's normal
Parameters
Returns
public function plus(n:Number):Vector
Adds a scalar to both the x and y components
Parameters
Returns
public function renderFrom(rX:Number, rY:Number, g:Graphics, col:uint = 0x660066):void
Render the vector from the given position
Parameters
| rX:Number — Global x starting position.
|
|
| rY:Number — Global y starting position.
|
|
| g:Graphics — A Graphics object to render to.
|
|
| col:uint (default = 0x660066 )
|
public function reverse():Vector
Reverses the vector's direction.
This is the same as multiplying by -1
Returns
public function rotate(ang:Number):Vector
Rotates the vector by the given degree.
Parameters
Returns
public function setAngle(ang:Number):void
Used to set the angle of the vector (in degrees).
Parameters
public function setPos(pX:Number, pY:Number):Vector
Quickly set the x and y values of the vector
Parameters
Returns
public function subtract(v:Vector):Vector
Vector subtraction.
Parameters
Returns
See also
public function times(n:Number):Vector
Multiplies both the x and y values by the given number.
This is usefull for scaling the vector without altering it's direction.
Parameters
Returns
public static function toAngle(dx:Number, dy:Number):Number
Returns a degree angle given its x and y components
Parameters
Returns
public function toString():String
Returns
public static function vectorBetween(v1:Vector, v2:Vector):Vector
Returns a vector starting at v1 and pointing to v2
Parameters
Returns
public static function vectorFromAngle(angle:Number, scale:Number = 1):Vector
Creates a vector given the angle and length
Parameters
| angle:Number — The angle of the desired vector in degrees.
|
|
| scale:Number (default = 1 ) — the magnitude of the desired vector.
|
Returns
public function vectorTo(v:Vector):Vector
Returns a vector starting at this vector and pointing to the given vector.
Parameters
Returns
FisixEngine 0.5a Documentation. For more engine support, visit www.fisixengine.com
Thu Dec 14 2006, 9:48 PM GMT-05:00