Packagecom.derschmale.wick3d.core.math
Classpublic class Vector3D
SubclassesVertex3D

The Vector3D class represents a point or a direction in 3D space.



Public Properties
 PropertyDefined by
  length : Number
[read-only] The length of the vector, or the distance from a point to the origin.
Vector3D
  lengthSquared : Number
[read-only] The squared length of the vector, or the squared distance from a point to the origin.
Vector3D
  w : Number
A number defining whether the vector is a direction vector (0) or a point (1).
Vector3D
  x : Number
The x-coordinate of the vector
Vector3D
  y : Number
The y-coordinate of the vector
Vector3D
  z : Number
The z-coordinate of the vector
Vector3D
Public Methods
 MethodDefined by
  
Vector3D(x:Number = 0, y:Number = 0, z:Number = 0, w:Number = 0)
Creates a new Vector3D object.
Vector3D
  
Adds a vector to the current vector, and returns the result as new instance.
Vector3D
  
Calculates the angle between two vectors.
Vector3D
  
Creates a new vector that is an exact duplicate of the current.
Vector3D
  
Calculates the cross product of two vectors
Vector3D
  
Deducts a vector from the current one.
Vector3D
  
distance(a:Vector3D, b:Vector3D):Number
[static] Calculates the distance between two points.
Vector3D
  
dotProduct(a:Vector3D):Number
Calculates the dot product of two vectors
Vector3D
  
equals(toCompare:Vector3D, allFour:Boolean = false):Boolean
Compares two vectors to see if they are equal.
Vector3D
  
Adds a vector to the current vector.
Vector3D
  
Multiplies this vector with a matrix;
Vector3D
  
nearEquals(toCompare:Vector3D, tolerance:Number = 0.0001, allFour:Boolean = false):Boolean
Compares two vectors to see if they are equal within a margin of error.
Vector3D
  
negate():void
Negates the current vector.
Vector3D
  
normalize():void
Scales the vector so it becomes unit length.
Vector3D
  
project():void
Divides the x, y and z coordinates by the w-component.
Vector3D
  
scaleBy(s:Number):void
Multiplies the vector by a scalar value
Vector3D
  
Deducts two vectors and returns the result as a new vector.
Vector3D
  
toString():String
Generates a string representation of the coordinates of the vector.
Vector3D
Public Constants
 ConstantDefined by
  XAXIS : Vector3D
[static] The absolute x-axis
Vector3D
  YAXIS : Vector3D
[static] The absolute y-axis
Vector3D
  ZAXIS : Vector3D
[static] The absolute z-axis
Vector3D
Property detail
lengthproperty
length:Number  [read-only]

The length of the vector, or the distance from a point to the origin.

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

The squared length of the vector, or the squared distance from a point to the origin.

Implementation
    public function get lengthSquared():Number
wproperty 
public var w:Number

A number defining whether the vector is a direction vector (0) or a point (1). Points are translated, whereas Vectors aren't.

xproperty 
public var x:Number

The x-coordinate of the vector

yproperty 
public var y:Number

The y-coordinate of the vector

zproperty 
public var z:Number

The z-coordinate of the vector

Constructor detail
Vector3D()constructor
public function Vector3D(x:Number = 0, y:Number = 0, z:Number = 0, w:Number = 0)

Creates a new Vector3D object.

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
 
w:Number (default = 0) — A number defining whether the vector is a direction vector (0) or a point (1)
Method detail
add()method
public function add(a:Vector3D):Vector3D

Adds a vector to the current vector, and returns the result as new instance.

Parameters
a:Vector3D

Returns
Vector3D — The sum of two vectors.
angleBetween()method 
public function angleBetween(a:Vector3D):Number

Calculates the angle between two vectors.

Parameters
a:Vector3D

Returns
Number — The angle between two vectors.
clone()method 
public function clone():Vector3D

Creates a new vector that is an exact duplicate of the current.

Returns
Vector3D — A clone of the current vector.
crossProduct()method 
public function crossProduct(a:Vector3D):Vector3D

Calculates the cross product of two vectors

Parameters
a:Vector3D

Returns
Vector3D — The cross product of two vectors.
decrementBy()method 
public function decrementBy(a:Vector3D):void

Deducts a vector from the current one.

Parameters
a:Vector3D
distance()method 
public static function distance(a:Vector3D, b:Vector3D):Number

Calculates the distance between two points.

Parameters
a:Vector3D
 
b:Vector3D

Returns
Number
dotProduct()method 
public function dotProduct(a:Vector3D):Number

Calculates the dot product of two vectors

Parameters
a:Vector3D

Returns
Number — The dot product of two vectors.
equals()method 
public function equals(toCompare:Vector3D, allFour:Boolean = false):Boolean

Compares two vectors to see if they are equal.

Parameters
toCompare:Vector3D — The vector to compare with the current.
 
allFour:Boolean (default = false) — Defines if the w-coordinate should be used in the comparison.

Returns
Boolean — Whether or not the vectors are equal.
incrementBy()method 
public function incrementBy(a:Vector3D):void

Adds a vector to the current vector.

Parameters
a:Vector3D
multiplyMatrix()method 
public function multiplyMatrix(m:Matrix3D):void

Multiplies this vector with a matrix;

Parameters
m:Matrix3D
nearEquals()method 
public function nearEquals(toCompare:Vector3D, tolerance:Number = 0.0001, allFour:Boolean = false):Boolean

Compares two vectors to see if they are equal within a margin of error.

Parameters
toCompare:Vector3D — The vector to compare with the current.
 
tolerance:Number (default = 0.0001) — The maximum difference that each component is allowed to have to be considered equal.
 
allFour:Boolean (default = false) — Defines if the w-coordinate should be used in the comparison.

Returns
Boolean — Whether or not the vectors are quasi equal.
negate()method 
public function negate():void

Negates the current vector.

normalize()method 
public function normalize():void

Scales the vector so it becomes unit length.

project()method 
public function project():void

Divides the x, y and z coordinates by the w-component.

scaleBy()method 
public function scaleBy(s:Number):void

Multiplies the vector by a scalar value

Parameters
s:Number
subtract()method 
public function subtract(a:Vector3D):Vector3D

Deducts two vectors and returns the result as a new vector.

Parameters
a:Vector3D

Returns
Vector3D — The difference between to vectors.
toString()method 
public function toString():String

Generates a string representation of the coordinates of the vector.

Returns
String — A String representation of the vector.
Constant detail
XAXISconstant
public static const XAXIS:Vector3D

The absolute x-axis

YAXISconstant 
public static const YAXIS:Vector3D

The absolute y-axis

ZAXISconstant 
public static const ZAXIS:Vector3D

The absolute z-axis