RS.Math.Vector2 Class Reference
[Math]
Description
A 2 Component vector.
Constructor
Functions
- Vector2 add( Vector2 rhs)
- Adds rhs to this vector and stores the result in this vector. More...
- clone()
- returns a copy of this vector.
- Number distance( Vector2 rhs)
- Returns the distance between the point specified by this vector and rhs. More...
- Vector2 divide( Vector2 rhs)
- Divide rhs into this vector and stores the result in this vector. More...
- Number dot( Vector2 rhs)
- Returns the dot product between this vector and rhs. More...
- Boolean equal( Vector2 rhs, Boolean use_tolerance)
- Returns true if this vector equals rhs. More...
- Boolean equal_with_tolerance( Vector2 rhs, Number tolerance)
- Returns true if this vector equals rhs using tolerance. More...
- Boolean is_colinear( Vector2 rhs)
- Returns true if this vector and rhs are colinear. More...
- Boolean is_null_vector( Number tolerance)
- Checks if the vector is the null vector. More...
- Number length()
- Returns the length of this vector. More...
- Vector2 multiply( Vector2 rhs)
- Multiplies rhs with this vector and stores the result in this vector. More...
- Vector2 normalize()
- Normalizes this vector. More...
- Vector2 scale( Number scale)
- Scales this vector. More...
- set( Object rhs)
- Sets this vector from an object. More...
- Vector2 subtract( Vector2 rhs)
- Subtracts rhs from this vector and stores the result in this vector. More...
- String toString()
- Returns a string describing this Object. More...
Constructor
- RS.Math.Vector2( Object vector)
-
Parameters
- vector
- Initial value. May be one of the following:
- Object
- Array
- Vector2
Functions
- Vector2 RS.Math.Vector2.add( Vector2 rhs)
-
Adds rhs to this vector and stores the result in this vector.
Parameters
- rhs
- the vector to add.
Returns
this
- RS.Math.Vector2.clone()
-
returns a copy of this vector.
- Number RS.Math.Vector2.distance( Vector2 rhs)
-
Returns the distance between the point specified by this vector and rhs.
Parameters
- rhs
- Vector2 RS.Math.Vector2.divide( Vector2 rhs)
-
Divide rhs into this vector and stores the result in this vector.
Parameters
- rhs
- the vector to multiply.
Returns
this
- Number RS.Math.Vector2.dot( Vector2 rhs)
-
Returns the dot product between this vector and rhs.
Parameters
- rhs
- Boolean RS.Math.Vector2.equal( Vector2 rhs, Boolean use_tolerance)
-
Returns true if this vector equals rhs.
Parameters
- rhs
- The vector to compare with.
- use_tolerance
- if supplied and true then use tolerance
- Boolean RS.Math.Vector2.equal_with_tolerance( Vector2 rhs, Number tolerance)
-
Returns true if this vector equals rhs using tolerance.
Parameters
- rhs
- The vector to compare with.
- tolerance
- The tolerance to use or RS.Math.ALMOST_ZERO if not supplied.
- Boolean RS.Math.Vector2.is_colinear( Vector2 rhs)
-
Returns true if this vector and rhs are colinear.
Parameters
- rhs
Returns
True if this vector and rhs are colinear
- Boolean RS.Math.Vector2.is_null_vector( Number tolerance)
-
Checks if the vector is the null vector.
Parameters
- tolerance
- Optional. A Number used to approximate the comparison.
- Number RS.Math.Vector2.length()
-
Returns the length of this vector.
- Vector2 RS.Math.Vector2.multiply( Vector2 rhs)
-
Multiplies rhs with this vector and stores the result in this vector.
Parameters
- rhs
- the vector to multiply.
Returns
this
- Vector2 RS.Math.Vector2.normalize()
-
Normalizes this vector.
Returns
this
- Vector2 RS.Math.Vector2.scale( Number scale)
-
Scales this vector.
Parameters
- scale
- Scale the scalar to apply.
Returns
this
- RS.Math.Vector2.set( Object rhs)
-
Sets this vector from an object. The object may be of the following types: Vector2, and Array with 3 or more members or an Object. In the case of an object it must have the members x, y, and z.
Parameters
- rhs
- The object to set from. May be one of the following:
- Object
- Array
- Vector2
- Vector2 RS.Math.Vector2.subtract( Vector2 rhs)
-
Subtracts rhs from this vector and stores the result in this vector.
Parameters
- rhs
- the vector to subtract.
Returns
this
- String RS.Math.Vector2.toString()
-
Returns a string describing this Object.
Returns
A String describing this Object.