Represents a mutable point in two-dimensional Cartesian coordinates.
Implements
- I
- I
- I
Members
Show:
Constructors
Creates an instance using the given coordinate pair.
Creates an instance using the given coordinate pair.
Parameters
- point: IPoint
- The coordinate.
Properties
final
Implements
IMutablePoint.xfinal
Implements
IMutablePoint.yMethods
Create a clone of this object.
Create a clone of this object.
Calculates the Euclidean distance between two points.
Calculates the Euclidean distance between two points.
Parameters
- point2: IPoint
- The second point.
Return Value
- number
- The distance between the two points.
Defined in
IPoint.distanceToParameters
- x: number
- the x coordinate of the second point
- y: number
- the y coordinate of the second point
Return Value
- number
- the Euclidean distance between this point and the point (x,y).
Defined in
IPoint.distanceTofinal
Parameters
- other: any
- the other object to compare for equality
Return Value
- boolean
trueifotheris considered equal to this instance.
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.
final
Return Value
- number
- the hash code for this object
Parameters
- x: number
- The new x-coordinate.
- y: number
- The new y-coordinate.
Defined in
IMutablePoint.setLocationThis method is useful to obtain a copy of the state and for making use of the various utility methods that are provided by Point.
Return Value
- Point
- The current values of the coordinates of the point.
See Also
Defined in
IPoint.toPointStatic Methods
Performs an implicit conversion from Point to MutablePoint.
Performs an implicit conversion from Point to MutablePoint.
static
Parameters
- point: Point
- The point to convert.
Return Value
- MutablePoint
- A mutable instance of the given point.
Examples
The following example shows how to convert a Point to a MutablePoint and back:
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.
Performs an explicit conversion from MutablePoint to Point.
static
Parameters
- p: MutablePoint
- The point to convert.
Return Value
- Point
- The result of the conversion.
Examples
The following example shows how to convert a Point to a MutablePoint and back:
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)