Basic 2D vector implementation.
angle:Number
[read-only]
Returns the angle represented by this Vector2, in radians.
Implementation
public function get angle():Number
length:Number
[read-write]
Returns this vector's length.
Implementation
public function get length():Number
public function set length(value:Number):void
lengthSquared:Number
[read-only]
Returns the square of this vector's length.
Implementation
public function get lengthSquared():Number
public var x:Number = 0
public var y:Number = 0
public function Vector2(x:Number = 0, y:Number = 0)
Constructs a Vector2 from the given values.
Parameters
| x:Number (default = 0 )
|
|
| y:Number (default = 0 )
|
public function add(v:Vector2):Vector2
Returns a copy of this vector added to 'v'.
Parameters
Returns
public function addLocal(v:Vector2):Vector2
Adds another Vector2 to this, in place.
Returns a reference to 'this', for chaining.
Parameters
Returns
public function clone():Vector2
Returns a copy of this Vector2.
Returns
public function dot(v:Vector2):Number
Returns the dot product of this vector with vector v.
Parameters
Returns
public function equals(v:Object):Boolean
Returns true if this vector is equal to v.
Parameters
Returns
public static function fromAngle(radians:Number, len:Number = 1):Vector2
Creates a Vector2 of magnitude 'len' that has been rotated about the origin by 'radians'.
Parameters
| radians:Number |
|
| len:Number (default = 1 )
|
Returns
public static function fromPoint(p:Point):Vector2
Converts Point p to a Vector2.
Parameters
Returns
public static function fromPoints(s:Point, t:Point):Vector2
Creates a new Vector2 pointing from s to t.
Parameters
Returns
public function getPerp(ccw:Boolean = true):Vector2
Returns a vector that is perpendicular to this one.
If ccw = true, the perpendicular vector is rotated 90 degrees counter-clockwise from this
vector, otherwise it's rotated 90 degrees clockwise.
Parameters
| ccw:Boolean (default = true )
|
Returns
public static function interpolate(a:Vector2, b:Vector2, p:Number):Vector2
Returns a new vector that is the linear interpolation of vectors a and b
at proportion p, where p is in [0, 1], p = 0 means the result is equal to a,
and p = 1 means the result is equal to b.
Parameters
Returns
public function invert():Vector2
Returns a copy of the vector, inverted.
Returns
public function invertLocal():Vector2
Inverts the vector.
Returns
public function normalize():Vector2
Returns a normalized copy of the vector.
Returns
public function normalizeLocal():Vector2
Normalizes this vector in place.
Returns a reference to 'this', for chaining.
Returns
public function normalizeLocalAndGetLength():Number
Normalizes the vector in place and returns its original length.
Returns
public function rotate(radians:Number):Vector2
Returns a rotated copy of this vector.
Parameters
Returns
public function rotateLocal(radians:Number):Vector2
Rotates the vector in place by 'radians'.
Returns a reference to 'this', for chaining.
Parameters
Returns
public function scale(value:Number):Vector2
Returns (this value).
Parameters
Returns
public function scaleLocal(value:Number):Vector2
Scales this vector by value.
Parameters
Returns
public function set(x:Number, y:Number):void
Sets the vector's components to the given values.
Parameters
public function similar(v:Vector2, epsilon:Number):Boolean
Returns true if the components of v are equal to the components of this Vector2,
within the given epsilon.
Parameters
Returns
public static function smallerAngleBetween(v1:Vector2, v2:Vector2):Number
Returns the smaller of the two angles between v1 and v2, in radians.
Result will be in range [0, pi].
Parameters
Returns
public function subtract(v:Vector2):Vector2
Returns (this - v).
Parameters
Returns
public function subtractLocal(v:Vector2):Vector2
Subtracts another vector from this one, in place.
Returns a reference to 'this', for chaining.
Parameters
Returns
public function toPoint():Point
Converts the Vector2 to a Point.
Returns
public function toString():String
Returns a string representation of the Vector2.
Returns
public static const INFINITE:Vector2
Infinite vector - often the result of normalizing a zero vector.
Copyright © 2007-2009 Three Rings Design, Inc.