Packagesandy.core.data
Classpublic final class Vector

A point in 3D world.

A representation of a position in a 3D space.



Public Properties
 PropertyDefined by
  x : Number
Vector
  y : Number
Vector
  z : Number
Vector
Public Methods
 MethodDefined by
  
Vector(p_nX:Number = 0, p_nY:Number = 0, p_nZ:Number = 0)
Creates a new vector instance.
Vector
  
add(v:Vector):void
Adds a specified vector to this vector.
Vector
  
Returns a clone of thei vector.
Vector
  
copy(p_oVector:Vector):void
Makes this vector a copy of the specified vector.
Vector
  
Computes and returns the cross between this vector and the specified vector.
Vector
  
deserialize(convertFrom:String):void
Sets the elements of this vector from a string representation.
Vector
  
dot(w:Vector):Number
Computes and returns the dot product between this vector and the specified vector.
Vector
  
equals(p_vector:Vector):Boolean
Is this vector equal to the specified vector?.
Vector
  
getAngle(w:Vector):Number
Returns the angle between this vector and the specified vector.
Vector
  
getMaxComponent():Number
Gives the biggest component of the current vector.
Vector
  
getMinComponent():Number
Gives the smallest component of the current vector.
Vector
  
getNorm():Number
Computes and returns the norm of this vector.
Vector
  
Compute and returns the invers of this vector.
Vector
  
normalize():void
Normalizes this vector.
Vector
  
pow(pow:Number):void
Raises this vector to the specified power.
Vector
  
reset():void
Reset the vector components to 0 after calling this method, x, y and z will be set to 0
Vector
  
Reset the vector components to the minimal value Flash can handle after calling this method, x, y and z will be set to Number.NEGATIVE_INFINITY;
Vector
  
Reset the vector components to the maximal value Flash can handle after calling this method, x, y and z will be set to Number.POSITIVE_INFINITY;
Vector
  
scale(n:Number):void
Multiplies this vector by the specified scalar.
Vector
  
serialize(decPlaces:Number = 0):String
Returns a string representation of this vector with rounded values.
Vector
  
sub(v:Vector):void
Substracts the specified vector from this vector.
Vector
  
toString(decPlaces:Number = 0):String
Returns a string representing this vector.
Vector
Property detail
xproperty
public var x:Number
yproperty 
public var y:Number
zproperty 
public var z:Number
Constructor detail
Vector()constructor
public function Vector(p_nX:Number = 0, p_nY:Number = 0, p_nZ:Number = 0)

Creates a new vector instance.

Parameters
p_nX:Number (default = 0) — the x coordinate
 
p_nY:Number (default = 0) — the y coordinate
 
p_nZ:Number (default = 0) — the z coordinate
Method detail
add()method
public final function add(v:Vector):void

Adds a specified vector to this vector.

Parameters
v:Vector — The vector to add
clone()method 
public final function clone():Vector

Returns a clone of thei vector.

Returns
Vector — The clone
copy()method 
public final function copy(p_oVector:Vector):void

Makes this vector a copy of the specified vector.

All elements of this vector is set to those of the argument vector

Parameters
p_oVector:Vector — The vector to copy
cross()method 
public final function cross(v:Vector):Vector

Computes and returns the cross between this vector and the specified vector.

Parameters
v:Vector — The vector to make the cross product with ( right side )

Returns
Vector — The cross product vector.
deserialize()method 
public final function deserialize(convertFrom:String):void

Sets the elements of this vector from a string representation.

[ToDo: Explain why this is good for XML intput! ]

Parameters
convertFrom:String — A string representing the vector ( specific serialize format )
dot()method 
public final function dot(w:Vector):Number

Computes and returns the dot product between this vector and the specified vector.

Parameters
w:Vector — The vector to multiply

Returns
Number — The dot procuct
equals()method 
public final function equals(p_vector:Vector):Boolean

Is this vector equal to the specified vector?.

Compares this vector with the vector passed in the argument.
If all components in the two vectors are equal a value of true is returned.

Parameters
p_vector:Vector

Returns
Boolean — true if the the two vectors are equal, fals otherwise.
getAngle()method 
public final function getAngle(w:Vector):Number

Returns the angle between this vector and the specified vector.

Parameters
w:Vector — The vector making an angle with this one

Returns
Number — The angle in radians
getMaxComponent()method 
public final function getMaxComponent():Number

Gives the biggest component of the current vector. Example : var lMax:Number = new Vector(5, 6.7, -4).getMaxComponent(); //returns 6.7

Returns
Number — The biggest component value of the vector
getMinComponent()method 
public final function getMinComponent():Number

Gives the smallest component of the current vector. Example : var lMin:Number = new Vector(5, 6.7, -4).getMinComponent(); //returns -4

Returns
Number — The smallest component value of the vector
getNorm()method 
public final function getNorm():Number

Computes and returns the norm of this vector.

The norm of the vector is sqrt( x + y + z )

Returns
Number — The norm
negate()method 
public final function negate():Vector

Compute and returns the invers of this vector.

Returns
Vector — The inverse
normalize()method 
public final function normalize():void

Normalizes this vector.

After normalizing the vector, the direction is the same, but the length is = 1.

pow()method 
public final function pow(pow:Number):void

Raises this vector to the specified power.

Each component of the vector is raised to the argument power.
So x = Math.pow( x, pow ), y = Math.pow( y, pow ),z = Math.pow( z, pow )

Parameters
pow:Number — {
reset()method 
public function reset():void

Reset the vector components to 0 after calling this method, x, y and z will be set to 0

resetToNegativeInfinity()method 
public function resetToNegativeInfinity():void

Reset the vector components to the minimal value Flash can handle after calling this method, x, y and z will be set to Number.NEGATIVE_INFINITY;

resetToPositiveInfinity()method 
public function resetToPositiveInfinity():void

Reset the vector components to the maximal value Flash can handle after calling this method, x, y and z will be set to Number.POSITIVE_INFINITY;

scale()method 
public final function scale(n:Number):void

Multiplies this vector by the specified scalar.

Parameters
n:Number — {
serialize()method 
public final function serialize(decPlaces:Number = 0):String

Returns a string representation of this vector with rounded values.

[ToDo: Explain why this is good for XML output! ]

Parameters
decPlaces:Number (default = 0) — Number of decimals

Returns
String — The specific serialize string
sub()method 
public final function sub(v:Vector):void

Substracts the specified vector from this vector.

Parameters
v:Vector — {
toString()method 
public final function toString(decPlaces:Number = 0):String

Returns a string representing this vector.

Parameters
decPlaces:Number (default = 0) — Number of decimals

Returns
String — The string representatation