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):VectorVector 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):NumberCalculates the angle between this vector to another
Parameters
Returns
public function clone():VectorReturns 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):NumberCalculates the distance squared between this vector to another
Parameters
Returns
public function distanceTo(v:Vector):NumberCalculates the distance between this vector to another
Parameters
Returns
public function divide(n:Number):VectorDivides 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):NumberDot product.
Parameters
Returns
public function getAngle():NumberThe angle of the vector in degrees.
Returns
public function getMagnitude():NumberReturns the magnitude, or length, of the vector.
Returns
public function getMagnitudeSquared():NumberReturns 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):VectorReturns the vector's right-hand normal
Parameters
Returns
public function minus(n:Number):VectorSubtracts a scalar from both the x and y components.
Parameters
Returns
public function normalize(len:Number = 1):VectorNormalizes 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):NumberPerpendicular product.
This is the same as using dot() with v's normal
Parameters
Returns
public function plus(n:Number):VectorAdds a scalar to both the x and y components
Parameters
Returns
public function renderFrom(rX:Number, rY:Number, g:Graphics, col:uint = 0x660066):voidRender 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():VectorReverses the vector's direction.
This is the same as multiplying by -1
Returns
public function rotate(ang:Number):VectorRotates the vector by the given degree.
Parameters
Returns
public function setAngle(ang:Number):voidUsed to set the angle of the vector (in degrees).
Parameters
public function setPos(pX:Number, pY:Number):VectorQuickly set the x and y values of the vector
Parameters
Returns
public function subtract(v:Vector):VectorVector subtraction.
Parameters
Returns
See also
public function times(n:Number):VectorMultiplies 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):NumberReturns a degree angle given its x and y components
Parameters
Returns
public function toString():String
Returns
public static function vectorBetween(v1:Vector, v2:Vector):VectorReturns a vector starting at v1 and pointing to v2
Parameters
Returns
public static function vectorFromAngle(angle:Number, scale:Number = 1):VectorCreates 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):VectorReturns 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