Packageorg.flintparticles.threeD.geom
Classpublic class Vector3D
InheritanceVector3D Inheritance org.flintparticles.threeD.geom.Transformable3D

Vector3D represents a vector in three-dimensional cartesian coordinate space.



Public Properties
 PropertyDefined by
  classType : Class
[read-only] Returns the actual type of the object - Point3D or Vector3D.
Vector3D
  length : Number
[read-only] The length of this vector.
Vector3D
  lengthSquared : Number
[read-only] The square of the length of this vector.
Vector3D
Public Methods
 MethodDefined by
  
Vector3D(x:Number = 0, y:Number = 0, z:Number = 0)
Constructor
Vector3D
  
add(v:Vector3D, result:Vector3D = null):Vector3D
Adds another vector to this one, returning the result.
Vector3D
  
Copies another vector into this one.
Vector3D
  
clone(result:Vector3D = null):Vector3D
Makes a copy of this vector.
Vector3D
  
Calculate the cross product of this vector with another.
Vector3D
  
Subtract another vector from this one.
Vector3D
  
divide(s:Number, result:Vector3D = null):Vector3D
Divide this vector by a number, returning the result.
Vector3D
  
divideBy(s:Number):Vector3D
Divide this vector by a number.
Vector3D
  
dotProduct(v:Vector3D):Number
Calculate the dot product of this vector with another.
Vector3D
  
equals(v:Vector3D):Boolean
Compare this vector to another.
Vector3D
  
Add another vector to this one.
Vector3D
  
multiply(s:Number, result:Vector3D = null):Vector3D
Multiply this vector by a number, returning the result.
Vector3D
  
nearEquals(v:Vector3D, e:Number):Boolean
Compare this vector to another.
Vector3D
  
Negate this vector.
Vector3D
  
negative(result:Vector3D = null):Vector3D
Get the negative of this vector - a vector the same length but in the opposite direction.
Vector3D
  
Convert this vector to have length 1.
Vector3D
  
reset(x:Number = 0, y:Number = 0, z:Number = 0):Vector3D
Assigns new coordinates to this vector
Vector3D
  
scaleBy(s:Number):Vector3D
Multiply this vector by a number.
Vector3D
  
subtract(v:Vector3D, result:Vector3D = null):Vector3D
Subtract another vector from this one, returning the result.
Vector3D
  
toString():String
Get a string representation of this vector
Vector3D
  
unit(result:Vector3D = null):Vector3D
Create a unit vector in the same direction as this one.
Vector3D
Public Constants
 ConstantDefined by
  AXISX : Vector3D
[static] A unit vector in the direction of the x axis.
Vector3D
  AXISY : Vector3D
[static] A unit vector in the direction of the y axis.
Vector3D
  AXISZ : Vector3D
[static] A unit vector in the direction of the z axis.
Vector3D
  ZERO : Vector3D
[static] A zero vector.
Vector3D
Property detail
classTypeproperty
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
lengthproperty 
length:Number  [read-only]

The length of this vector.

Implementation
    public function get length():Number
lengthSquaredproperty 
lengthSquared:Number  [read-only]

The square of the length of this vector.

Implementation
    public function get lengthSquared():Number
Constructor detail
Vector3D()constructor
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
Method detail
add()method
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
Vector3D — the result of the addition
assign()method 
public function assign(v:Vector3D):Vector3D

Copies another vector into this one.

Parameters
v:Vector3D — The vector to copy

Returns
Vector3D — a reference to this vector
clone()method 
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
Vector3D — A copy of this Vector3D
crossProduct()method 
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
decrementBy()method 
public function decrementBy(v:Vector3D):Vector3D

Subtract another vector from this one.

Parameters
v:Vector3D — The vector to subtract

Returns
Vector3D — A reference to this vector.
divide()method 
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
Vector3D — The result of the division
divideBy()method 
public function divideBy(s:Number):Vector3D

Divide this vector by a number.

Parameters
s:Number — The number to divide by

Returns
Vector3D — A reference to this vector.
dotProduct()method 
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
equals()method 
public function equals(v:Vector3D):Boolean

Compare this vector to another.

Parameters
v:Vector3D — The vector to compare with

Returns
Boolean — true if the vectors have the same coordinates, false otherwise
incrementBy()method 
public function incrementBy(v:Vector3D):Vector3D

Add another vector to this one.

Parameters
v:Vector3D — The vector to add

Returns
Vector3D — A reference to this vector.
multiply()method 
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
nearEquals()method 
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
negate()method 
public function negate():Vector3D

Negate this vector. The sign of the x, y, and z coordinates is changed.

Returns
Vector3D — a reference to this vector.
negative()method 
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
Vector3D — the negative of this vector
normalize()method 
public function normalize():Vector3D

Convert this vector to have length 1.

Returns
Vector3D — A reference to this vector.
reset()method 
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
Vector3D — a reference to this vector
scaleBy()method 
public function scaleBy(s:Number):Vector3D

Multiply this vector by a number.

Parameters
s:Number — The number to multiply by

Returns
Vector3D — A reference to this vector.
subtract()method 
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
toString()method 
public function toString():String

Get a string representation of this vector

Returns
String — a string representation of this vector
unit()method 
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.
Constant detail
AXISXconstant
public static const AXISX:Vector3D

A unit vector in the direction of the x axis.

AXISYconstant 
public static const AXISY:Vector3D

A unit vector in the direction of the y axis.

AXISZconstant 
public static const AXISZ:Vector3D

A unit vector in the direction of the z axis.

ZEROconstant 
public static const ZERO:Vector3D

A zero vector.