The goog.math.Line Class

goog.math.Line(x0, y0, x1, y1)

Object representing a line.

x0 {number}
X coordinate of the start point.
y0 {number}
Y coordinate of the start point.
x1 {number}
X coordinate of the end point.
y1 {number}
Y coordinate of the end point.

.clone()

returns {!goog.math.Line}
A copy of this line.

.equals(other)

Tests whether the given line is exactly the same as this one.

other {goog.math.Line}
The other line.
returns {boolean}
Whether the given line is the same as this one.

.getClosestPoint(x, opt_y)

Computes the point on the line closest to a given point. Note that a line in this case is defined as the infinite line going through the start and end points. To find the closest point on the line segment itself see {@see #getClosestSegmentPoint}.

x {number|goog.math.Coordinate}
The x coordinate of the point, or a coordinate object.
opt_y {number=}
The y coordinate of the point - required if x is a number, ignored if x is a goog.math.Coordinate.
returns {!goog.math.Coordinate}
The point on the line closest to the given point.

.getClosestSegmentPoint(x, opt_y)

Computes the point on the line segment closest to a given point.

x {number|goog.math.Coordinate}
The x coordinate of the point, or a coordinate object.
opt_y {number=}
The y coordinate of the point - required if x is a number, ignored if x is a goog.math.Coordinate.
returns {!goog.math.Coordinate}
The point on the line segment closest to the given point.

.getInterpolatedPoint(t)

Returns the point on the line segment proportional to t, where for t = 0 we return the starting point and for t = 1 we return the end point. For t < 0 or t > 1 we extrapolate along the line defined by the line segment.

t {number}
The interpolation parameter along the line segment.
returns {!goog.math.Coordinate}
The point on the line segment at t.

.getSegmentLength()

returns {number}
The length of the line segment used to define the line.

.getSegmentLengthSquared()

returns {number}
The squared length of the line segment used to define the line.

.x0 {number}

X coordinate of the first point.

.x1 {number}

X coordinate of the first control point.

.y0 {number}

Y coordinate of the first point.

.y1 {number}

Y coordinate of the first control point.