Class goog.math.Coordinate
code »Class for representing coordinates and positions.
Constructor
Instance Methods
code »ceil ( ) ⇒ !goog.math.CoordinateRounds the x and y fields to the next larger integer values.
!goog.math.Coordinate| Returns |
|---|
|
code »clone ( ) ⇒ !goog.math.CoordinateReturns a new copy of the coordinate.
!goog.math.Coordinate| Returns |
|---|
|
code »floor ( ) ⇒ !goog.math.CoordinateRounds the x and y fields to the next smaller integer values.
!goog.math.Coordinate| Returns |
|---|
|
code »rotateDegrees ( degrees, opt_center )Rotates this coordinate clockwise about the origin (or, optionally, the given
center) by the given angle, in degrees.
| Parameters |
|---|
|
code »rotateRadians ( radians, opt_center )Rotates this coordinate clockwise about the origin (or, optionally, the given
center) by the given angle, in radians.
| Parameters |
|---|
|
code »round ( ) ⇒ !goog.math.CoordinateRounds the x and y fields to the nearest integer values.
!goog.math.Coordinate| Returns |
|---|
|
code »scale ( sx, opt_sy ) ⇒ !goog.math.CoordinateScales 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.
!goog.math.Coordinatesx and opt_sy respectively. If opt_sy
is not given, then sx is used for both x and y.code »translate ( tx, opt_ty ) ⇒ !goog.math.CoordinateTranslates 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.
!goog.math.Coordinategoog.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.| Parameters |
|---|
|
| Returns |
|
Instance Properties
Static Functions
Returns the angle from the origin to a coordinate.
| Parameters |
|---|
|
| Returns |
a. |
Returns the difference between two coordinates as a new
goog.math.Coordinate.
| Parameters |
|---|
|
| Returns |
a and b. |
code »goog.math.Coordinate.distance ( a, b ) ⇒ numberReturns the distance between two coordinates.
number| Parameters |
|---|
|
| Returns |
a and b. |
code »goog.math.Coordinate.equals ( a, b ) ⇒ booleanCompares coordinates for equality.
boolean| Parameters |
|---|
|
| Returns |
|
Returns the magnitude of a coordinate.
| Parameters |
|---|
|
| Returns |
a. |
code »goog.math.Coordinate.squaredDistance ( a, b ) ⇒ numberReturns 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.)
number| Parameters |
|---|
|
| Returns |
a and b. |
code »goog.math.Coordinate.sum ( a, b ) ⇒ !goog.math.CoordinateReturns the sum of two coordinates as a new goog.math.Coordinate.
!goog.math.Coordinate| Parameters |
|---|
|
| Returns |
|