Represents a mutable point in two-dimensional Cartesian coordinates.
Type Details
- yFiles module
- core
See Also
Constructors
Properties
Methods
Create a clone of this object.
Calculates the Euclidean distance between two points.
Parameters
A map of options to pass to the method.
- point2 - IPoint
- The second point.
Returns
- ↪number
- The distance between the two points.
Overrides
Returns the euclidean distance between this point and a given point.
Parameters
A map of options to pass to the method.
- x - number
- the x coordinate of the second point
- y - number
- the y coordinate of the second point
Returns
- ↪number
- the Euclidean distance between this point and the point (x,y).
Overrides
Returns a hash code for this object.
Remarks
The hash code is a numeric value that can be used to treat this object as a key in a hash table or similar data structure.
Two objects that are considered equal must have the same hash code. However, the reverse does not hold and two objects having the same hash code don't have to be equal. Ideally, the hash code should be roughly uniformly-distributed to prevent hash tables from performing poorly. Calculating the hash code is also a potentially frequent operation and should therefore be fast.
Returns
- ↪number
- the hash code for this object
Static Methods
Performs an implicit conversion from Point to MutablePoint.
Parameters
A map of options to pass to the method.
- point - Point
- The point to convert.
Returns
- ↪MutablePoint
- A mutable instance of the given point.
Examples
const point = new Point(10, 15)
console.log(`Initial point: ${point}`) // (10, 15)
const mPoint = point.toMutablePoint()
// The following also works, due to an implicit conversion:
const mPoint2 = point
mPoint.x = 42
const point2 = mPoint.toPoint()
// The following also works, due an explicit conversion:
const point3 = mPoint
console.log(`Changed point: ${point2}`) // (42, 15)
Performs an explicit conversion from MutablePoint to Point.
Parameters
A map of options to pass to the method.
- p - MutablePoint
- The point to convert.
Returns
- ↪Point
- The result of the conversion.
Examples
const point = new Point(10, 15)
console.log(`Initial point: ${point}`) // (10, 15)
const mPoint = point.toMutablePoint()
// The following also works, due to an implicit conversion:
const mPoint2 = point
mPoint.x = 42
const point2 = mPoint.toPoint()
// The following also works, due an explicit conversion:
const point3 = mPoint
console.log(`Changed point: ${point2}`) // (42, 15)