Vector3D represents a vector in three-dimensional cartesian
coordinate space.
classType:Class [read-only]
Returns the actual type of the object - Point3D or Vector3D. Used by some
matrix operations.
Implementation
public function get classType():Class
length:Number [read-only]
The length of this vector.
Implementation
public function get length():Number
lengthSquared:Number [read-only]
The square of the length of this vector.
Implementation
public function get lengthSquared():Number
public function Vector3D(x:Number = 0, y:Number = 0, z:Number = 0)
Constructor
Parameters
| x:Number (default = 0) — the x coordinate of the vector
|
| |
| y:Number (default = 0) — the y coordinate of the vector
|
| |
| z:Number (default = 0) — the z coordinate of the vector
|
public function add(v:Vector3D, result:Vector3D = null):Vector3D
Adds another vector to this one, returning the result.
Parameters
| v:Vector3D — the vector to add
|
| |
| result:Vector3D (default = null) — The vector to hold the result of the addition. If
no vector is passed, a new vector is created.
|
Returns
public function assign(v:Vector3D):Vector3D
Copies another vector into this one.
Parameters
Returns
public function clone(result:Vector3D = null):Vector3D
Makes a copy of this vector.
Parameters
| result:Vector3D (default = null) — The vector to hold the copy of this vector. If
no vector is passed, a new vector is created.
|
Returns
public function crossProduct(v:Vector3D, result:Vector3D = null):Vector3D
Calculate the cross product of this vector with another.
Parameters
| v:Vector3D — The vector to calculate the cross product with
|
| |
| result:Vector3D (default = null) — The vector to hold the result of the cross product. If
no vector is passed, a new vector is created.
|
Returns
| Vector3D —
The cross product of the two vectors
|
public function decrementBy(v:Vector3D):Vector3D
Subtract another vector from this one.
Parameters
Returns
public function divide(s:Number, result:Vector3D = null):Vector3D
Divide this vector by a number, returning the result.
Parameters
| s:Number — The number to divide by
|
| |
| result:Vector3D (default = null) — The vector to hold the result of the divide. If
no vector is passed, a new vector is created.
|
Returns
public function divideBy(s:Number):Vector3D
Divide this vector by a number.
Parameters
| s:Number — The number to divide by
|
Returns
public function dotProduct(v:Vector3D):Number
Calculate the dot product of this vector with another.
Parameters
| v:Vector3D — The vector to calculate the dot product with
|
Returns
| Number — The dot product of the two vectors
|
public function equals(v:Vector3D):Boolean
Compare this vector to another.
Parameters
Returns
| Boolean — true if the vectors have the same coordinates, false otherwise
|
public function incrementBy(v:Vector3D):Vector3D
Add another vector to this one.
Parameters
Returns
public function multiply(s:Number, result:Vector3D = null):Vector3D
Multiply this vector by a number, returning the result.
Parameters
| s:Number — The number to multiply by
|
| |
| result:Vector3D (default = null) — The vector to hold the result of the multiplication. If
no vector is passed, a new vector is created.
|
Returns
| Vector3D —
The result of the multiplication
|
public function nearEquals(v:Vector3D, e:Number):Boolean
Compare this vector to another.
Parameters
| v:Vector3D — The vector to compare with
|
| |
| e:Number — The variance allowed between the two vectors
|
Returns
| Boolean — true if the vectors are within
variance e of each other, false otherwise
|
public function negate():Vector3D
Negate this vector. The sign of the x, y, and z coordinates is changed.
Returns
public function negative(result:Vector3D = null):Vector3D
Get the negative of this vector - a vector the same length but in the
opposite direction. The sign of the x, y and z coordinates is changed.
Parameters
| result:Vector3D (default = null) — The vector to hold the result of the negation. If
no vector is passed, a new vector is created.
|
Returns
public function normalize():Vector3D
Convert this vector to have length 1.
Returns
public function reset(x:Number = 0, y:Number = 0, z:Number = 0):Vector3D
Assigns new coordinates to this vector
Parameters
| x:Number (default = 0) — The new x coordinate
|
| |
| y:Number (default = 0) — The new y coordinate
|
| |
| z:Number (default = 0) — The new z coordinate
|
Returns
public function scaleBy(s:Number):Vector3D
Multiply this vector by a number.
Parameters
| s:Number — The number to multiply by
|
Returns
public function subtract(v:Vector3D, result:Vector3D = null):Vector3D
Subtract another vector from this one, returning the result.
Parameters
| v:Vector3D — The vector to subtract
|
| |
| result:Vector3D (default = null) — The vector to hold the result of the subtraction. If
no vector is passed, a new vector is created.
|
Returns
| Vector3D —
The result of the subtraction
|
public function toString():String
Get a string representation of this vector
Returns
| String — a string representation of this vector
|
public function unit(result:Vector3D = null):Vector3D
Create a unit vector in the same direction as this one.
Parameters
| result:Vector3D (default = null) — The vector to hold the unit vector result. If
no vector is passed, a new vector is created.
|
Returns
| Vector3D —
A unit vector in the same direction as this one.
|
public static const AXISX:Vector3D
A unit vector in the direction of the x axis.
public static const AXISY:Vector3D
A unit vector in the direction of the y axis.
public static const AXISZ:Vector3D
A unit vector in the direction of the z axis.
public static const ZERO:Vector3D
A zero vector.
© Richard Lord 2010