goog.math.Vec2
Instance Methods
this.add( b ) → goog.math.Vec2
goog.math.Vec2
Adds another vector to this vector in-place.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.ceil() → goog.math.Coordinate
goog.math.Coordinate
Rounds the x and y fields to the next larger integer values.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.clone() → goog.math.Vec2
goog.math.Vec2
Returns a new copy of the coordinate.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.equals( other ) → boolean
boolean
Returns whether the specified value is equal to this coordinate.
Overrides | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.floor() → goog.math.Coordinate
goog.math.Coordinate
Rounds the x and y fields to the next smaller integer values.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.invert() → goog.math.Vec2
goog.math.Vec2
Reverses the sign of the vector. Equivalent to scaling the vector by -1.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.magnitude() → number
number
Returns the magnitude of the vector measured from the origin.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.normalize() → goog.math.Vec2
goog.math.Vec2
Normalizes the current vector to have a magnitude of 1.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.rotate( angle ) → goog.math.Vec2
goog.math.Vec2
Rotates this vector in-place by a given angle, specified in radians.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.rotateDegrees( degrees, opt_center ) → void
void
Rotates this coordinate clockwise about the origin (or, optionally, the given center) by the given angle, in degrees.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.rotateRadians( radians, opt_center ) → void
void
Rotates this coordinate clockwise about the origin (or, optionally, the given center) by the given angle, in radians.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.round() → goog.math.Coordinate
goog.math.Coordinate
Rounds the x and y fields to the nearest integer values.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.scale( sx, opt_sy ) → goog.math.Vec2
goog.math.Vec2
Scales this coordinate by the given scale factors. The x and y values are
scaled by sx
and opt_sy
respectively. If opt_sy
is not given, then sx
is used for both x and y.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.squaredMagnitude() → number
number
Returns the squared magnitude of the vector measured from the origin. NOTE(brenneman): Leaving out the square root is not a significant optimization in JavaScript.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.subtract( b ) → goog.math.Vec2
goog.math.Vec2
Subtracts another vector from this vector in-place.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.toString() → string
string
Returns a nice string representing the coordinate.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.translate( tx, opt_ty ) → goog.math.Coordinate
goog.math.Coordinate
Translates this box by the given offsets. If a goog.math.Coordinate
is given, then the x and y values are translated by the coordinate's x and y.
Otherwise, x and y are translated by tx
and opt_ty
respectively.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
Instance Properties
this.x → number
number
this.y → number
number
Static Functions
Vec2.determinant( a, b ) → number
number
Returns the determinant of two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.difference( a, b ) → goog.math.Vec2
goog.math.Vec2
Returns the difference between two vectors as a new Vec2.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.distance( a, b ) → number
number
Returns the distance between two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.dot( a, b ) → number
number
Returns the dot-product of two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.equals( a, b ) → boolean
boolean
Compares vectors for equality.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.fromCoordinate( a ) → goog.math.Vec2
goog.math.Vec2
Returns a new Vec2 object from a given coordinate.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Vec2.lerp( a, b, x ) → goog.math.Vec2
goog.math.Vec2
Returns a new Vec2 that is the linear interpolant between vectors a and b at scale-value x.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.random() → goog.math.Vec2
goog.math.Vec2
Parameters | None. | ||
---|---|---|---|
Returns |
|
Vec2.randomUnit() → goog.math.Vec2
goog.math.Vec2
Parameters | None. | ||
---|---|---|---|
Returns |
|
Vec2.rescaled( a, sx, sy ) → goog.math.Vec2
goog.math.Vec2
Returns a new Vec2 that is a copy of the vector a, but rescaled by a factors sx and sy in the x and y directions. If only sx is specified, then y is scaled by the same factor as x.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.rotateAroundPoint( v, axisPoint, angle ) → goog.math.Vec2
goog.math.Vec2
Rotates a vector by a given angle, specified in radians, relative to a given axis rotation point. The returned vector is a newly created instance - no in-place changes are done.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.squaredDistance( a, b ) → number
number
Returns the squared distance between two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec2.sum( a, b ) → goog.math.Vec2
goog.math.Vec2
Returns the sum of two vectors as a new Vec2.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|