Package | shared.math |
Class | public class Vec2 |
Inheritance | Vec2 ![]() ![]() |
See also
Property | Defined By | ||
---|---|---|---|
angle : Number Vector angle in radians (can be assigned to) | Vec2 | ||
length : Number Length of the vector (can be assigned to) | Vec2 | ||
stringDecimals : int = 4 [static] Number of decimal places to show when using toString() (set this to -1 for default Number -> String conversion) | Vec2 | ||
x : Number X component | Vec2 | ||
y : Number X component | Vec2 |
Method | Defined By | ||
---|---|---|---|
Vec2(x:Number = 0, y:Number = 0) | Vec2 | ||
![]() | Adds "pos" vector (returns a new Vec2) | Vec2Const | |
Adds "pos" vector | Vec2 | ||
![]() | Adds ("x", "y") (returns a new Vec2) | Vec2Const | |
Adds ("x", "y") | Vec2 | ||
![]() | Returns a new Vec2 clamped to "maxLen" length | Vec2Const | |
![]() | clampInRect(rectangle:Rectangle):Vec2 Clamps this vector to fit in the specified "rectangle" (returns a new Vec2) | Vec2Const | |
clampInRectSelf(rectangle:Rectangle):Vec2 Clamps this vector to fit in the specified "rectangle" | Vec2 | ||
Clamps this vector to "maxLen" length | Vec2 | ||
![]() | Clamps this vector to specified components (returns a new Vec2) | Vec2Const | |
clampXYSelf(minX:Number, maxX:Number, minY:Number, maxY:Number):Vec2 Clamps this vector to specified components | Vec2 | ||
![]() | Returns a new Vec2, replica of this instance | Vec2Const | |
![]() | Computes the cross product (determinant) with "vec" | Vec2Const | |
![]() | crossDetXY(x:Number, y:Number):Number Computes the cross product (determinant) with ("x", "y")) | Vec2Const | |
![]() | Computes the distance from "vec" vector | Vec2Const | |
![]() | distanceSqr(vec:Vec2Const):Number Computes the squared distance from "vec" vector | Vec2Const | |
![]() | distanceXY(x:Number, y:Number):Number Computes the distance from ("x", "y") | Vec2Const | |
![]() | distanceXYSqr(x:Number, y:Number):Number Computes the distance from ("x", "y") | Vec2Const | |
![]() | Divides by "vec" vector (returns a new Vec2) | Vec2Const | |
Divides by "vec" vector | Vec2 | ||
![]() | Divides by ("x", "y") (returns a new Vec2) | Vec2Const | |
Divides by ("x", "y") | Vec2 | ||
![]() | Computes the dot product with "vec" vector | Vec2Const | |
![]() | dotXY(x:Number, y:Number):Number Computes the dot product with "vec" vector | Vec2Const | |
![]() | Returns true if this vector's components equal the ones of "vec" | Vec2Const | |
![]() | equalsXY(x:Number, y:Number):Boolean Returns true if this vector's components equal ("x", "y") | Vec2Const | |
![]() | Returns a new Vec2 with negated components | Vec2Const | |
Negates components | Vec2 | ||
[static] Creates a Vec2 from an AS3 Point (or any "p" object exposing x, y properties) | Vec2 | ||
[static] Sets components converting from polar coords (returns a new Vec2) | Vec2 | ||
fromPolarSelf(rads:Number, length:Number):Vec2 Sets components converting from polar coords | Vec2 | ||
![]() | getDegrees():Number Vector angle in degrees | Vec2Const | |
![]() | Returns a new Vec2 which is the maximum between this vector and "vec" (component-wise) | Vec2Const | |
![]() | Returns a new Vec2 which is the minimum between this vector and "vec" (component-wise) | Vec2Const | |
![]() | getRads():Number Vector angle in radians | Vec2Const | |
![]() | getRadsBetween(vec:Vec2Const):Number Angle between this vector and "vec" in radians | Vec2Const | |
![]() | Returns true if this vector is near "vec2" | Vec2Const | |
![]() | isNearXY(x:Number, y:Number):Boolean Returns true if this vector is near ("x", "y") | Vec2Const | |
![]() | isNormalized():Boolean Returns true if this vector is normalized (length == 1) | Vec2Const | |
![]() | isValid():Boolean Returns true if is a valid vector (has finite components) | Vec2Const | |
![]() | Returns true if the distance from "vec2" vector is lesser than "epsilon" | Vec2Const | |
![]() | isWithinXY(x:Number, y:Number, epsilon:Number):Boolean Returns true if the distance from ("x", "y") vector is lesser than "epsilon" | Vec2Const | |
![]() | isZero():Boolean Returns true if this vector's components are 0 | Vec2Const | |
![]() | lengthSqr():Number Computes the squared length of the vector | Vec2Const | |
![]() | Linear interpolation from this vector to "to" vector (returns a new Vec2) | Vec2Const | |
Linear interpolation from this vector to "to" vector | Vec2 | ||
![]() | Multiplies by "vec" vector (returns a new Vec2) | Vec2Const | |
Multiplies by "vec" vector | Vec2 | ||
![]() | Multiplies by ("x", "y") (returns a new Vec2) | Vec2Const | |
Multiplies by ("x", "y") | Vec2 | ||
![]() | Normalizes the vector (returns a new Vec2) | Vec2Const | |
normalizeSelf(length:Number = 1):Vec2 Normalizes the vector | Vec2 | ||
![]() | Returns a new Vec2 left-perpendicular to this vector | Vec2Const | |
Sets components to be left-perpendicular to this vector | Vec2 | ||
![]() | Returns a new Vec2 right-perpendicular to this vector | Vec2Const | |
Sets components to be right-perpendicular to this vector | Vec2 | ||
![]() | Reflect this vector in plane whose normal is "normal" (returns a new Vec2) | Vec2Const | |
![]() | Rotates by "rads" radians (returns a new Vec2) | Vec2Const | |
rotateSelf(rads:Number):Vec2 Rotates by "rads" radians | Vec2 | ||
![]() | Rotates using spinor "vec" (returns a new Vec2) | Vec2Const | |
Rotates using spinor "vec" | Vec2 | ||
![]() | Scales by the scalar "s" (returns a new Vec2) | Vec2Const | |
Scales by the scalar "s" | Vec2 | ||
Copies x and y components from "p" (where "p" is any object exposing x, y properties) | Vec2 | ||
Copies x and y components from passed arguments | Vec2 | ||
![]() |
Spherical linear interpolation from this vector to "to" vector (returns a new Vec2) - not thoroughly tested
Note: this vector and "vec" MUST be orthogonal for it to work properly
| Vec2Const | |
![]() | Gets spinor between this vector and "vec" (returns a new Vec2) | Vec2Const | |
![]() | Subtracts "pos" vector (returns a new Vec2) | Vec2Const | |
Subtracts "pos" vector | Vec2 | ||
![]() | Subtracts ("x", "y") (returns a new Vec2) | Vec2Const | |
Subtracts ("x", "y") | Vec2 | ||
[static] Swaps vectors | Vec2 | ||
![]() | toPoint():Point Creates an AS3 Point from this vector | Vec2Const | |
![]() | toString():String String representation of this vector (uses Vec2Const.stringDecimals decimal positions) | Vec2Const | |
![]() | Returns a new Vec2 which is a unit for this vector (same as normalize(1)) | Vec2Const | |
Sets x and y components to 0 | Vec2 |
Constant | Defined By | ||
---|---|---|---|
Epsilon : Number = 0.0000001 [static] Epsilon (maximum error for comparisons) | Vec2 | ||
EpsilonSqr : Number = 9.999999999999998E-15 [static] Epsilon squared | Vec2 | ||
RAD2DEG : Number = 57.29577951308232 [static] Constant to convert from radians to degrees | Vec2 | ||
Zero : Vec2Const [static] Zero vector | Vec2 |
angle | property |
angle:Number
Vector angle in radians (can be assigned to)
public function get angle():Number
public function set angle(value:Number):void
length | property |
length:Number
Length of the vector (can be assigned to)
public function get length():Number
public function set length(value:Number):void
stringDecimals | property |
public static var stringDecimals:int = 4
Number of decimal places to show when using toString() (set this to -1 for default Number -> String conversion)
x | property |
x:Number
X component
public function get x():Number
public function set x(value:Number):void
y | property |
y:Number
X component
public function get y():Number
public function set y(value:Number):void
Vec2 | () | Constructor |
public function Vec2(x:Number = 0, y:Number = 0)
x:Number (default = 0 )
| |
y:Number (default = 0 )
|
addSelf | () | method |
addXYSelf | () | method |
public function addXYSelf(x:Number, y:Number):Vec2
Adds ("x", "y")
Parameters
x:Number | |
y:Number |
Vec2 |
clampInRectSelf | () | method |
public function clampInRectSelf(rectangle:Rectangle):Vec2
Clamps this vector to fit in the specified "rectangle"
Parameters
rectangle:Rectangle |
Vec2 |
clampSelf | () | method |
public function clampSelf(maxLen:Number):Vec2
Clamps this vector to "maxLen" length
Parameters
maxLen:Number |
Vec2 |
clampXYSelf | () | method |
public function clampXYSelf(minX:Number, maxX:Number, minY:Number, maxY:Number):Vec2
Clamps this vector to specified components
Parameters
minX:Number | |
maxX:Number | |
minY:Number | |
maxY:Number |
Vec2 |
divSelf | () | method |
public function divSelf(vec:Vec2Const):Vec2
Divides by "vec" vector
Parameters
vec:Vec2Const |
Vec2 |
divXYSelf | () | method |
public function divXYSelf(x:Number, y:Number):Vec2
Divides by ("x", "y")
Parameters
x:Number | |
y:Number |
Vec2 |
flipSelf | () | method |
fromPoint | () | method |
public static function fromPoint(p:*):Vec2
Creates a Vec2 from an AS3 Point (or any "p" object exposing x, y properties)
Parameters
p:* |
Vec2 |
fromPolar | () | method |
public static function fromPolar(rads:Number, length:Number):Vec2
Sets components converting from polar coords (returns a new Vec2)
Parameters
rads:Number | |
length:Number |
Vec2 |
fromPolarSelf | () | method |
public function fromPolarSelf(rads:Number, length:Number):Vec2
Sets components converting from polar coords
Parameters
rads:Number | |
length:Number |
Vec2 |
lerpSelf | () | method |
public function lerpSelf(to:Vec2Const, t:Number):Vec2
Linear interpolation from this vector to "to" vector
Parameters
to:Vec2Const | |
t:Number |
Vec2 |
mulSelf | () | method |
public function mulSelf(vec:Vec2Const):Vec2
Multiplies by "vec" vector
Parameters
vec:Vec2Const |
Vec2 |
mulXYSelf | () | method |
public function mulXYSelf(x:Number, y:Number):Vec2
Multiplies by ("x", "y")
Parameters
x:Number | |
y:Number |
Vec2 |
normalizeSelf | () | method |
public function normalizeSelf(length:Number = 1):Vec2
Normalizes the vector
Parameters
length:Number (default = 1 )
|
Vec2 |
perpLeftSelf | () | method |
public function perpLeftSelf():Vec2
Sets components to be left-perpendicular to this vector
ReturnsVec2 |
perpRightSelf | () | method |
public function perpRightSelf():Vec2
Sets components to be right-perpendicular to this vector
ReturnsVec2 |
rotateSelf | () | method |
public function rotateSelf(rads:Number):Vec2
Rotates by "rads" radians
Parameters
rads:Number |
Vec2 |
rotateSpinorSelf | () | method |
public function rotateSpinorSelf(vec:Vec2Const):Vec2
Rotates using spinor "vec"
Parameters
vec:Vec2Const |
Vec2 |
scaleSelf | () | method |
set | () | method |
public function set(p:*):Vec2
Copies x and y components from "p" (where "p" is any object exposing x, y properties)
Parameters
p:* |
Vec2 |
setXY | () | method |
public function setXY(x:Number, y:Number):Vec2
Copies x and y components from passed arguments
Parameters
x:Number | |
y:Number |
Vec2 |
subSelf | () | method |
public function subSelf(pos:Vec2Const):Vec2
Subtracts "pos" vector
Parameters
pos:Vec2Const |
Vec2 |
subXYSelf | () | method |
public function subXYSelf(x:Number, y:Number):Vec2
Subtracts ("x", "y")
Parameters
x:Number | |
y:Number |
Vec2 |
swap | () | method |
zero | () | method |
Epsilon | Constant |
public static const Epsilon:Number = 0.0000001
Epsilon (maximum error for comparisons)
EpsilonSqr | Constant |
public static const EpsilonSqr:Number = 9.999999999999998E-15
Epsilon squared
RAD2DEG | Constant |
public static const RAD2DEG:Number = 57.29577951308232
Constant to convert from radians to degrees
Zero | Constant |
public static const Zero:Vec2Const
Zero vector