Class Point2
Defined in: lina.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Point2(x, y)
Point in 2D space that has an internal cartesian representation (x/y)
and support for transformations.
|
Method Attributes | Method Name and Description |
---|---|
copy()
Return a new copy of this point.
|
|
distanceTo(pt2, y)
Return distance from this to pt2.
|
|
<static> |
Point2.distanceTo(pt1, pt2, y)
Return distance from this to pt2.
|
<static> |
Point2.isEqual(pt1, pt2, eps)
Check if pt2 is (aproximately) equal to pt1.
|
isEqual(pt2, eps)
Check if pt2 is (aproximately) equal to this.
|
|
mdistance(pt2)
Return Manhattan-Distance from this to pt2.
|
|
<static> |
Point2.rotate(pt, a, ptCenter)
Return rotated copy of pt.
|
rotate(a, ptCenter)
Rotate this point (in-place) and return this instance.
|
|
set(x, y)
Set coordinates.
|
|
sqrDistanceTo(pt2, y)
Return squared distance from this to pt2.
|
|
toString(prec)
Return string representation '(x/y)'.
|
|
<static> |
Point2.transform(pt, m)
Return a copy of pt transformed by m.
|
transform(m)
Apply transformation matrix (in-place) and return this instance.
|
|
translate(vecOrDx, dy)
Translate point (in-place) and return this instance.
|
|
<static> |
Point2.translate(pt, dx, dy)
Return a translated copy of pt.
|
vectorTo(pt2, y)
Return vector from this to pt2.
|
|
<static> |
Point2.vectorTo(pt1, pt2, y)
Return vector from pt1 to pt2.
|
Class Detail
Point2(x, y)
Point in 2D space that has an internal cartesian representation (x/y)
and support for transformations.
When applying transformations, a point is handled as [x, y, 1].
var pt1 = new Point2(3, 4); pt1.rotate(Math.PI).translate(1, 2); var pt2 = new Point2({x:2, y:1}); var dist = pt1.distanceTo(pt2)
- Parameters:
- {float|Point2|JS-object} x
- X-coordinate or a Point2 instance or {x:_, y:_}
- {float} y
- Y-coordinate or undefined, if x is a Point2 instance or {x:_, y:_}
Method Detail
{Point2}
copy()
Return a new copy of this point.
- Returns:
- {Point2}
{float}
distanceTo(pt2, y)
Return distance from this to pt2. .
- Parameters:
- {Point2|JS-Object} pt2
- Second point.
- y
- Returns:
- {float}
<static>
{float}
Point2.distanceTo(pt1, pt2, y)
Return distance from this to pt2.
- Returns:
- {float}
<static>
{boolean}
Point2.isEqual(pt1, pt2, eps)
Check if pt2 is (aproximately) equal to pt1.
- Parameters:
- {Point2|JS-Object} pt1
- First point.
- {Point2|JS-Object} pt2
- Second point.
- {float} eps
- (optional) accepted maximum distance.
- Returns:
- {boolean}
{boolean}
isEqual(pt2, eps)
Check if pt2 is (aproximately) equal to this.
- Parameters:
- {Point2|JS-Object} pt2
- Second point.
- {float} eps
- (optional) accepted maximum distance.
- Returns:
- {boolean}
{float}
mdistance(pt2)
Return Manhattan-Distance from this to pt2.
- Parameters:
- {Point2} pt2
- (optional) Second point.
- Returns:
- {float}
<static>
{Point2}
Point2.rotate(pt, a, ptCenter)
Return rotated copy of pt.
- Parameters:
- {Point2} pt
- point that will be rotaded.
- {float} a
- Angle in radians.
- {Point2} ptCenter
- (optional) center of rotation, defaults to (0/0).
- Returns:
- {Point2}
{Point2}
rotate(a, ptCenter)
Rotate this point (in-place) and return this instance.
- Parameters:
- {float} a
- Angle in radians.
- {Point2} ptCenter
- (optional) center of rotation, defaults to (0/0).
- Returns:
- {Point2}
{Point2}
set(x, y)
Set coordinates.
- Parameters:
- {float|Point2|JS-object} x
- X-coordinate or a Point2 instance or {x:_, y:_}
- {float} y
- Y-coordinate or undefined, if x is a Point2 instance or {x:_, y:_}
- Returns:
- {Point2}
{float}
sqrDistanceTo(pt2, y)
Return squared distance from this to pt2. .
- Parameters:
- {Point2|JS-Object} pt2
- Second point.
- y
- Returns:
- {float}
toString(prec)
Return string representation '(x/y)'.
- Parameters:
- prec
<static>
{Point2}
Point2.transform(pt, m)
Return a copy of pt transformed by m.
- Returns:
- {Point2}
{Point2}
transform(m)
Apply transformation matrix (in-place) and return this instance.
- Parameters:
- m
- Returns:
- {Point2}
{Point2}
translate(vecOrDx, dy)
Translate point (in-place) and return this instance.
- Parameters:
- {float|Vec2} vecOrDx
- x-offset or offset vector
- {float|undefined} dy
- y-offset (omit this parameter, if x is a Vec2)
- Returns:
- {Point2}
<static>
{Point2}
Point2.translate(pt, dx, dy)
Return a translated copy of pt.
- Parameters:
- {Point2} pt
- point that will be translated.
- {float|Vec2} dx
- x-offset or offset vector
- {float|undefined} dy
- y-offset (omit this parameter, if x is a Vec2)
- Returns:
- {Point2}
{Vec2}
vectorTo(pt2, y)
Return vector from this to pt2.
- Parameters:
- {Point2|JS-Object} pt2
- Second point.
- y
- Returns:
- {Vec2}
<static>
{float}
Point2.vectorTo(pt1, pt2, y)
Return vector from pt1 to pt2.
- Returns:
- {float}