Class Index | File Index

Classes


Class R.math.Vector2D


Extends R.math.Point2D.
A 2D vector class with helpful manipulation methods.
Defined in: vector2d.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Create a new 2D Vector
Field Summary
Field Attributes Field Name and Description
<static>  
R.math.Vector2D.DOWN
The normalized "down" vector.
<static>  
R.math.Vector2D.LEFT
The normalized "left" vector.
<static>  
R.math.Vector2D.RIGHT
The normalized "right" vector.
<static>  
R.math.Vector2D.UP
The normalized "up" vector.
<static>  
R.math.Vector2D.ZERO
The "zero" vector.
Method Summary
Method Attributes Method Name and Description
 
angleBetween(vector)
Returns the angle (in degrees) between two vectors.
 
cross(vector)
A mutator method that gets the cross product of this vector and another.
 
dot(vector)
Get the dot product of this vector and another.
 
Get the angle, in degrees, of this vector.
 
Return the classname of the this object
 
getSign(vector)
Is the vector to the right or left of this one?
 
Returns true if this vector is anti-parallel to vector.
 
isParallelTo(vector)
Returns true if this vector is parallel to vector.
 
Returns true if this vector is perpendicular to vector.
 
len()
Get the magnitude/length of this vector.
 
A mutator method that normalizes this vector, returning a unit length vector.
 
perProduct(vector)
Get the perproduct (sign) of this vector and vector.
 
projectOnto(vector)
Project this vector onto vector.
 
Get the right-hand normal of this vector.
 
rotate(angle, axis)
Mutator method that modifies the vector rotated angle degrees about the vector defined by axis.
 
setAngle(angle)
Set the angle of this vector without altering the length
 
setLen(len)
Set the magnitude/length of this vector without altering the angle
 
Returns the signed angle (in degrees) between two vectors.
Methods borrowed from class R.math.Point2D:
add, addScalar, convolve, convolveInverse, dist, div, equals, isZero, mul, neg, release, set, setX, setY, simplify, sub, toString, transform
Methods borrowed from class R.math.PooledMathObject:
destroy
Methods borrowed from class R.engine.PooledObject:
clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toXML
Class Detail
R.math.Vector2D(x, y)
Create a new 2D Vector
Parameters:
x
{R.math.Vector2D|Number} If this arg is a Vector2D, its values will be copied into the new vector. If a number, the X length of the vector.
y
{Number} The Y length of the vector. Only required if X was a number.
Field Detail
<static> R.math.Vector2D.DOWN
The normalized "down" vector. This vector should not be modified.

<static> R.math.Vector2D.LEFT
The normalized "left" vector. This vector should not be modified.

<static> R.math.Vector2D.RIGHT
The normalized "right" vector. This vector should not be modified.

<static> R.math.Vector2D.UP
The normalized "up" vector. This vector should not be modified.

<static> R.math.Vector2D.ZERO
The "zero" vector. This vector should not be modified.
Method Detail
{Number} angleBetween(vector)
Returns the angle (in degrees) between two vectors. This assumes that the point is being used to represent a vector, and that the supplied point is also a vector.
Parameters:
vector
{R.math.Vector2D} The vector to perform the angular determination against
Returns:
{Number} The angle between two vectors, in degrees

{R.math.Vector2D} cross(vector)
A mutator method that gets the cross product of this vector and another.
Parameters:
vector
{R.math.Vector2D} The vector to perform the operation against.
Returns:
{R.math.Vector2D} This vector

{Number} dot(vector)
Get the dot product of this vector and another.
Parameters:
vector
{R.math.Vector2D} The Point to perform the operation against.
Returns:
{Number} The dot product

{Number} getAngle()
Get the angle, in degrees, of this vector.
Returns:
{Number}

{String} getClassName()
Return the classname of the this object
Returns:
{String} "R.math.Vector2D"

{Number} getSign(vector)
Is the vector to the right or left of this one?
Parameters:
vector
{R.math.Vector2D} The vectore to compare against
Returns:
{Number} -1 (left) 1 (right)

{Boolean} isAntiparallelTo(vector)
Returns true if this vector is anti-parallel to vector.
Parameters:
vector
{R.math.Vector2D} The vector to compare against
Returns:
{Boolean}

{Boolean} isParallelTo(vector)
Returns true if this vector is parallel to vector.
Parameters:
vector
{R.math.Vector2D} The vector to compare against
Returns:
{Boolean}

{Boolean} isPerpendicularTo(vector)
Returns true if this vector is perpendicular to vector.
Parameters:
vector
{R.math.Vector2D} The vector to compare against
Returns:
{Boolean}

{Number} len()
Get the magnitude/length of this vector.
Returns:
{Number} A value representing the length (magnitude) of the vector.

{R.math.Vector2D} normalize()
A mutator method that normalizes this vector, returning a unit length vector.
Returns:
{R.math.Vector2D} This vector, normalized
See:
#len

{Number} perProduct(vector)
Get the perproduct (sign) of this vector and vector. Returns -1 if vector is to the left, or 1 if it is to the right of this vector.
Parameters:
vector
{R.math.Vector2D} The other vector
Returns:
{Number}

{R.math.Vector2D} projectOnto(vector)
Project this vector onto vector.
Parameters:
vector
{R.math.Vector2D} The vector to project onto
Returns:
{R.math.Vector2D}

{R.math.Vector2D} rightNormal()
Get the right-hand normal of this vector. The left-hand normal would simply be this.rightNormal().neg().
Returns:
{R.math.Vector2D}

{R.math.Vector2D} rotate(angle, axis)
Mutator method that modifies the vector rotated angle degrees about the vector defined by axis.
Parameters:
angle
{Number} The rotation angle in degrees
axis
{R.math.Vector2D} The axis to rotate about
Returns:
{R.math.Vector2D} This vector

setAngle(angle)
Set the angle of this vector without altering the length
Parameters:
angle
{Number} The angle

setLen(len)
Set the magnitude/length of this vector without altering the angle
Parameters:
len
{Number} The length

{Number} signedAngleBetween(vector)
Returns the signed angle (in degrees) between two vectors. This assumes that the point is being used to represent a vector, and that the supplied point is also a vector.
Parameters:
vector
{R.math.Vector2D} The vector to perform the angular determination against
Returns:
{Number} The angle between two vectors, in degrees

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Mar 18 2013 16:09:19 GMT-0400 (EDT)