Packagepegas.geom
Classpublic class Vector2
ImplementsGeometry
SubclassesPoint, Vector3

Represents a vector in a 2D world with the coordinates x, y.



Public Properties
 PropertyDefined by
  x : Number
Defined the x coordinate.
Vector2
  y : Number
Defined the y coordinate.
Vector2
  ZERO : Vector2
[static] Defines the Vector2 object with the x and y properties set to zero.
Vector2
Public Methods
 MethodDefined by
  
Vector2(x:Number = 0, y:Number = 0)
Creates a new Vector2 instance.
Vector2
  
addition(v:*):void
Computes the addition of two vectors.
Vector2
  
clone():*
Returns a shallow copy of this instance.
Vector2
  
equals(o:*):Boolean
Compares the specified object with this object for equality.
Vector2
  
scale(value:Number):void
Scales the vector object with the input value.
Vector2
  
substraction(v:*):void
Computes the substraction of the current vector object with an other.
Vector2
  
toFlash():Point
Returns a flash.geom.Point reference of this object.
Vector2
  
toObject():Object
Returns the Object representation of this object.
Vector2
  
toSource(indent:int = 0):String
Returns the source code string representation of the object.
Vector2
  
toString():String
Returns the string representation of the object.
Vector2
Property detail
xproperty
public var x:Number

Defined the x coordinate.

yproperty 
public var y:Number

Defined the y coordinate.

ZEROproperty 
public static var ZERO:Vector2

Defines the Vector2 object with the x and y properties set to zero.

Constructor detail
Vector2()constructor
public function Vector2(x:Number = 0, y:Number = 0)

Creates a new Vector2 instance.

Parameters
x:Number (default = 0) — the x coordinate.
 
y:Number (default = 0) — the y coordinate.
Method detail
addition()method
public function addition(v:*):void

Computes the addition of two vectors.

Parameters
v:* — the vector object to add.
clone()method 
public function clone():*

Returns a shallow copy of this instance.

Returns
* — a shallow copy of this instance.
equals()method 
public function equals(o:*):Boolean

Compares the specified object with this object for equality.

Parameters
o:*

Returns
Booleantrue if the the specified object is equal with this object.
scale()method 
public function scale(value:Number):void

Scales the vector object with the input value.

Parameters
value:Number — a real number to scale the current vector object.
substraction()method 
public function substraction(v:*):void

Computes the substraction of the current vector object with an other.

Parameters
v:* — the vector to substract.
toFlash()method 
public function toFlash():Point

Returns a flash.geom.Point reference of this object.

Returns
Point — a flash.geom.Point reference of this object.
toObject()method 
public function toObject():Object

Returns the Object representation of this object.

Returns
Object — the Object representation of this object.
toSource()method 
public function toSource(indent:int = 0):String

Returns the source code string representation of the object.

Parameters
indent:int (default = 0)

Returns
String — the source code string representation of the object.
toString()method 
public function toString():String

Returns the string representation of the object.

Returns
String — the string representation of the object.