Class Point
A Point represents an x- and y-coordinate pair in two-dimensional space.
Use the static functions Point.parse and Point.stringify to convert to and from a standard string representation that is independent of the current locale.
When an instance of this class is the value of a property of a GraphObject class or Diagram or CommandHandler or a Tool class, you should treat the object as if it were frozen or read-only -- you cannot modify its properties. This allows the property to return a value without allocating a new instance. If you need to do your own calculations with the value, call copy to make a new instance with the same values that you can modify.
Many methods modify the object's properties and then return a reference to "this" object. The only instance method to allocate a new object is the copy method. The static Point.parse method also allocates a new object.
The "Debug" implementation of this class is significantly slower than the "Release" implementation, mostly due to additional error checking.
You cannot inherit from this class.
Constructor Summary Details
| Returns | Name | Description |
|---|---|---|
|
Point(x, y)
|
The default constructor produces the Point(0,0). More...
This constructor may take either zero arguments or two arguments.
|
Properties Summary Details
| Returns | Name | Description |
|---|---|---|
{number}
|
x
|
Gets or sets the x value of the Point.
|
{number}
|
y
|
Gets or sets the y value of the Point.
|
Method Summary Details
| Returns | Name | Description |
|---|---|---|
{Point}
|
add(p)
|
|
{Point}
|
copy()
|
Create a copy of this Point, with the same values.
|
{number}
|
direction(px, py)
|
Compute the angle from this Point to a given (px,py) point. More...
However, if the point is the same as this Point, the direction is zero.
See also:
|
<static>
{number}
|
Point.direction(px, py, qx, qy)
|
This static function returns the angle in degrees of the line from point P to point Q. More...
|
{number}
|
directionPoint(p)
|
Compute the angle from this Point to a given Point. More...
However, if the given Point is the same as this Point, the direction is zero.
See also:
|
<static>
{number}
|
Point.distanceLineSegmentSquared(px, py, ax, ay, bx, by)
|
This static function returns the square of the distance from the point P
to the finite line segment from point A to point B. More...
|
{number}
|
distanceSquared(px, py)
|
Returns the square of the distance from this point to a given point (px, py). More...
See also:
|
<static>
{number}
|
Point.distanceSquared(px, py, qx, qy)
|
This static function returns the square of the distance from the point P to the point Q. More...
|
{number}
|
distanceSquaredPoint(p)
|
|
{boolean}
|
equals(p)
|
|
{boolean}
|
equalTo(x, y)
|
|
{boolean}
|
isReal()
|
True if this Point has X and Y values that are real numbers and not infinity.
|
{Point}
|
normalize()
|
|
{Point}
|
offset(dx, dy)
|
|
<static>
{Point}
|
Point.parse(str)
|
This static function can be used to read in a Point from a string that was produced by Point.stringify. More...
|
{Point}
|
projectOntoLineSegment(px, py, qx, qy)
1.3
|
Modify this point to be the closest point to this point that is on a finite line segment. More...
|
{Point}
|
projectOntoLineSegmentPoint(p, q)
1.3
|
|
{Point}
|
rotate(angle)
|
|
{Point}
|
scale(sx, sy)
|
|
{Point}
|
set(p)
|
|
{Point}
|
setRectSpot(r, spot)
|
Modify this Point so that its X and Y values correspond to a particular Spot
in a given Rect. More...
The result is meaningless if Spot.isNoSpot is true for the given Spot. See also:
|
{Point}
|
setSpot(x, y, w, h, spot)
|
Modify this Point so that its X and Y values correspond to a particular Spot
in a given rectangle. More...
The result is meaningless if Spot.isNoSpot is true for the given Spot. See also:
|
{Point}
|
setTo(x, y)
|
|
{Point}
|
snapToGrid(originx, originy, cellwidth, cellheight)
1.3
|
Modify this point to be at the nearest point on an infinite grid,
given the grid's origin and size of each grid cell. More...
|
{Point}
|
snapToGridPoint(origin, cellsize)
1.3
|
|
<static>
{string}
|
Point.stringify(val)
|
This static function can be used to write out a Point as a string that can be read by Point.parse. More...
|
{Point}
|
subtract(p)
|