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
| 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
| Name, Value Type | Description |
|---|---|
|
x
{number}
|
Gets or sets the x value of the Point. |
|
y
{number}
|
Gets or sets the y value of the Point. |
Method Summary Details
| Name, Return Type | Description |
|---|---|
|
add(p)
{Point}
|
|
|
copy()
{Point}
|
Create a copy of this Point, with the same values.
|
|
direction(px, py)
{number}
|
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>
Point.direction(px, py, qx, qy)
{number}
|
This static function returns the angle in degrees of the line from point P to point Q.More...
|
|
directionPoint(p)
{number}
|
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>
Point.distanceLineSegmentSquared(px, py, ax, ay, bx, by)
{number}
|
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...
|
|
distanceSquared(px, py)
{number}
|
Returns the square of the distance from this point to a given point (px, py).More... See also:
|
|
<static>
Point.distanceSquared(px, py, qx, qy)
{number}
|
This static function returns the square of the distance from the point P to the point Q.More...
|
|
distanceSquaredPoint(p)
{number}
|
|
|
equals(p)
{boolean}
|
|
|
equalTo(x, y)
{boolean}
|
|
|
isReal()
{boolean}
|
True if this Point has X and Y values that are real numbers and not infinity.
|
|
normalize()
{Point}
|
|
|
offset(dx, dy)
{Point}
|
|
|
<static>
Point.parse(str)
{Point}
|
This static function can be used to read in a Point from a string that was produced by Point.stringify.More...
|
|
projectOntoLineSegment(px, py, qx, qy)
{Point}
1.3
|
Modify this point to be the closest point to this point that is on a finite line segment.More...
|
|
projectOntoLineSegmentPoint(p, q)
{Point}
1.3
|
|
|
rotate(angle)
{Point}
|
|
|
scale(sx, sy)
{Point}
|
|
|
set(p)
{Point}
|
|
|
setRectSpot(r, spot)
{Point}
|
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:
|
|
setSpot(x, y, w, h, spot)
{Point}
|
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:
|
|
setTo(x, y)
{Point}
|
|
|
snapToGrid(originx, originy, cellwidth, cellheight)
{Point}
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...
|
|
snapToGridPoint(origin, cellsize)
{Point}
1.3
|
|
|
<static>
Point.stringify(val)
{string}
|
This static function can be used to write out a Point as a string that can be read by Point.parse.More...
|
|
subtract(p)
{Point}
|