| Package | com.lookbackon.AI.steeringBehavior |
| Class | public class Vector2D |
| Inheritance | Vector2D Object |
| Property | Defined By | ||
|---|---|---|---|
| angle : Number
Gets / sets the angle of this vector. | Vector2D | ||
| length : Number
Sets / gets the length or magnitude of this vector. | Vector2D | ||
| lengthSQ : Number [read-only]
Gets the length of this vector, squared. | Vector2D | ||
| perp : Vector2D [read-only]
Finds a vector that is perpendicular to this vector. | Vector2D | ||
| x : Number
Sets / gets the x value of this vector. | Vector2D | ||
| y : Number
Sets / gets the y value of this vector. | Vector2D | ||
| Method | Defined By | ||
|---|---|---|---|
Vector2D(x:Number = 0, y:Number = 0)
Constructor. | Vector2D | ||
Adds a vector to this vector, creating a new Vector2D instance to hold the result. | Vector2D | ||
[static]
Calculates the angle between two vectors. | Vector2D | ||
Generates a copy of this vector. | Vector2D | ||
Calculates the cross product of this vector and another given vector. | Vector2D | ||
Calculates the distance from this vector to another given vector. | Vector2D | ||
Calculates the distance squared from this vector to another given vector. | Vector2D | ||
Divides this vector by a value, creating a new Vector2D instance to hold the result. | Vector2D | ||
Calculates the dot product of this vector and another given vector. | Vector2D | ||
draw(graphics:Graphics, color:uint = 0):void
Can be used to visualize the vector. | Vector2D | ||
Indicates whether this vector and another Vector2D instance are equal in value. | Vector2D | ||
isNormalized():Boolean
Whether or not this vector is normalized, i.e. | Vector2D | ||
isZero():Boolean
Whether or not this vector is equal to zero, i.e. | Vector2D | ||
Multiplies this vector by a value, creating a new Vector2D instance to hold the result. | Vector2D | ||
Normalizes this vector. | Vector2D | ||
Reverses the direction of this vector. | Vector2D | ||
Determines if a given vector is to the right or left of this vector. | Vector2D | ||
Subtacts a vector to this vector, creating a new Vector2D instance to hold the result. | Vector2D | ||
toString():String
Generates a string representation of this vector. | Vector2D | ||
Ensures the length of the vector is no longer than the given value. | Vector2D | ||
Sets this vector's x and y values, and thus length, to zero. | Vector2D | ||
| angle | property |
angle:NumberGets / sets the angle of this vector. Changing the angle changes the x and y but retains the same length.
public function get angle():Number public function set angle(value:Number):void| length | property |
length:NumberSets / gets the length or magnitude of this vector. Changing the length will change the x and y but not the angle of this vector.
public function get length():Number public function set length(value:Number):void| lengthSQ | property |
lengthSQ:Number [read-only] Gets the length of this vector, squared.
public function get lengthSQ():Number| perp | property |
perp:Vector2D [read-only] Finds a vector that is perpendicular to this vector.
public function get perp():Vector2D| x | property |
x:NumberSets / gets the x value of this vector.
public function get x():Number public function set x(value:Number):void| y | property |
y:NumberSets / gets the y value of this vector.
public function get y():Number public function set y(value:Number):void| Vector2D | () | Constructor |
public function Vector2D(x:Number = 0, y:Number = 0)Constructor.
Parametersx:Number (default = 0) | |
y:Number (default = 0) |
| add | () | method |
public function add(v2:Vector2D):Vector2DAdds a vector to this vector, creating a new Vector2D instance to hold the result.
Parameters
v2:Vector2D — A Vector2D instance.
|
Vector2D — Vector2D A new vector containing the results of the addition.
|
| angleBetween | () | method |
public static function angleBetween(v1:Vector2D, v2:Vector2D):NumberCalculates the angle between two vectors.
Parameters
v1:Vector2D — The first Vector2D instance.
| |
v2:Vector2D — The second Vector2D instance.
|
Number — Number the angle between the two given vectors.
|
| clone | () | method |
public function clone():Vector2DGenerates a copy of this vector.
ReturnsVector2D — Vector2D A copy of this vector.
|
| crossProd | () | method |
public function crossProd(v2:Vector2D):NumberCalculates the cross product of this vector and another given vector.
Parameters
v2:Vector2D — Another Vector2D instance.
|
Number — Number The cross product of this vector and the one passed in as a parameter.
|
| dist | () | method |
public function dist(v2:Vector2D):NumberCalculates the distance from this vector to another given vector.
Parameters
v2:Vector2D — A Vector2D instance.
|
Number — Number The distance from this vector to the vector passed as a parameter.
|
| distSQ | () | method |
public function distSQ(v2:Vector2D):NumberCalculates the distance squared from this vector to another given vector.
Parameters
v2:Vector2D — A Vector2D instance.
|
Number — Number The distance squared from this vector to the vector passed as a parameter.
|
| divide | () | method |
public function divide(value:Number):Vector2DDivides this vector by a value, creating a new Vector2D instance to hold the result.
Parameters
value:Number — A Vector2D instance.
|
Vector2D — Vector2D A new vector containing the results of the division.
|
| dotProd | () | method |
public function dotProd(v2:Vector2D):NumberCalculates the dot product of this vector and another given vector.
Parameters
v2:Vector2D — Another Vector2D instance.
|
Number — Number The dot product of this vector and the one passed in as a parameter.
|
| draw | () | method |
public function draw(graphics:Graphics, color:uint = 0):voidCan be used to visualize the vector. Generally used for debug purposes only.
Parameters
graphics:Graphics — The Graphics instance to draw the vector on.
| |
color:uint (default = 0) — The color of the line used to represent the vector.
|
| equals | () | method |
public function equals(v2:Vector2D):BooleanIndicates whether this vector and another Vector2D instance are equal in value.
Parameters
v2:Vector2D — A Vector2D instance.
|
Boolean — Boolean True if the other vector is equal to this one, false if not.
|
| isNormalized | () | method |
public function isNormalized():BooleanWhether or not this vector is normalized, i.e. its length is equal to one.
ReturnsBoolean — Boolean True if length is one, otherwise false.
|
| isZero | () | method |
public function isZero():BooleanWhether or not this vector is equal to zero, i.e. its x, y, and length are zero.
ReturnsBoolean — Boolean True if vector is zero, otherwise false.
|
| multiply | () | method |
public function multiply(value:Number):Vector2DMultiplies this vector by a value, creating a new Vector2D instance to hold the result.
Parameters
value:Number — A Vector2D instance.
|
Vector2D — Vector2D A new vector containing the results of the multiplication.
|
| normalize | () | method |
public function normalize():Vector2DNormalizes this vector. Equivalent to setting the length to one, but more efficient.
ReturnsVector2D — Vector2D A reference to this vector.
|
| reverse | () | method |
public function reverse():Vector2DReverses the direction of this vector.
ReturnsVector2D — Vector2D A reference to this vector.
|
| sign | () | method |
public function sign(v2:Vector2D):intDetermines if a given vector is to the right or left of this vector.
Parameters
v2:Vector2D |
int — int If to the left, returns -1. If to the right, +1.
|
| subtract | () | method |
public function subtract(v2:Vector2D):Vector2DSubtacts a vector to this vector, creating a new Vector2D instance to hold the result.
Parameters
v2:Vector2D — A Vector2D instance.
|
Vector2D — Vector2D A new vector containing the results of the subtraction.
|
| toString | () | method |
public function toString():StringGenerates a string representation of this vector.
ReturnsString — String A description of this vector.
|
| truncate | () | method |
public function truncate(max:Number):Vector2DEnsures the length of the vector is no longer than the given value.
Parameters
max:Number — The maximum value this vector should be. If length is larger than max, it will be truncated to this value.
|
Vector2D — Vector2D A reference to this vector.
|
| zero | () | method |
public function zero():Vector2DSets this vector's x and y values, and thus length, to zero.
ReturnsVector2D — Vector2D A reference to this vector.
|