math.Coordinate Extends
Class for representing coordinates and positions.

Inheritance

Constructor

goog.math.Coordinate(opt_xopt_y)

Parameters

opt_x : number=
Left, defaults to 0.
opt_y : number=
Top, defaults to 0.

Instance Methods

Public Protected Private
ceil() !goog.math.Coordinate
Rounds the x and y fields to the next larger integer values.
Returns: !goog.math.Coordinate  This coordinate with ceil'd fields.
code »
clone() !goog.math.Coordinate
Returns a new copy of the coordinate.
Returns: !goog.math.Coordinate  A clone of this coordinate.
code »
floor() !goog.math.Coordinate
Rounds the x and y fields to the next smaller integer values.
Returns: !goog.math.Coordinate  This coordinate with floored fields.
code »
rotateDegrees(degreesopt_center)
Rotates this coordinate clockwise about the origin (or, optionally, the given center) by the given angle, in degrees.
Arguments:
degrees : number
The angle by which to rotate this coordinate clockwise about the given center, in degrees.
opt_center : !goog.math.Coordinate=
The center of rotation. Defaults to (0, 0) if not given.
code »
rotateRadians(radiansopt_center)
Rotates this coordinate clockwise about the origin (or, optionally, the given center) by the given angle, in radians.
Arguments:
radians : number
The angle by which to rotate this coordinate clockwise about the given center, in radians.
opt_center : !goog.math.Coordinate=
The center of rotation. Defaults to (0, 0) if not given.
code »
round() !goog.math.Coordinate
Rounds the x and y fields to the nearest integer values.
Returns: !goog.math.Coordinate  This coordinate with rounded fields.
code »
scale(sxopt_sy) !goog.math.Coordinate
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.
Arguments:
sx : number
The scale factor to use for the x dimension.
opt_sy : number=
The scale factor to use for the y dimension.
Returns: !goog.math.Coordinate  This coordinate after scaling.
code »
toString() string
Returns a nice string representing the coordinate.
Returns: string  In the form (50, 73).
code »
translate(txopt_ty) !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.
Arguments:
tx : number | goog.math.Coordinate
The value to translate x by or the the coordinate to translate this coordinate by.
opt_ty : number=
The value to translate y by.
Returns: !goog.math.Coordinate  This coordinate after translating.
code »

Instance Properties

x :
X-value
Code »
y :
Y-value
Code »

Static Methods

goog.math.Coordinate.azimuth(a) number
Returns the angle from the origin to a coordinate.
Arguments:
a : !goog.math.Coordinate
A Coordinate.
Returns: number  The angle, in degrees, clockwise from the positive X axis to a.
code »
goog.math.Coordinate.difference(ab) !goog.math.Coordinate
Returns the difference between two coordinates as a new goog.math.Coordinate.
Arguments:
a : !goog.math.Coordinate
A Coordinate.
b : !goog.math.Coordinate
A Coordinate.
Returns: !goog.math.Coordinate  A Coordinate representing the difference between a and b.
code »
goog.math.Coordinate.distance(ab) number
Returns the distance between two coordinates.
Arguments:
a : !goog.math.Coordinate
A Coordinate.
b : !goog.math.Coordinate
A Coordinate.
Returns: number  The distance between a and b.
code »
goog.math.Coordinate.equals(ab) boolean
Compares coordinates for equality.
Arguments:
a : goog.math.Coordinate
A Coordinate.
b : goog.math.Coordinate
A Coordinate.
Returns: boolean  True iff the coordinates are equal, or if both are null.
code »
goog.math.Coordinate.magnitude(a) number
Returns the magnitude of a coordinate.
Arguments:
a : !goog.math.Coordinate
A Coordinate.
Returns: number  The distance between the origin and a.
code »
goog.math.Coordinate.squaredDistance(ab) number
Returns the squared distance between two coordinates. Squared distances can be used for comparisons when the actual value is not required. Performance note: eliminating the square root is an optimization often used in lower-level languages, but the speed difference is not nearly as pronounced in JavaScript (only a few percent.)
Arguments:
a : !goog.math.Coordinate
A Coordinate.
b : !goog.math.Coordinate
A Coordinate.
Returns: number  The squared distance between a and b.
code »
goog.math.Coordinate.sum(ab) !goog.math.Coordinate
Returns the sum of two coordinates as a new goog.math.Coordinate.
Arguments:
a : !goog.math.Coordinate
A Coordinate.
b : !goog.math.Coordinate
A Coordinate.
Returns: !goog.math.Coordinate  A Coordinate representing the sum of the two coordinates.
code »

Package math

Package Reference