C

MutablePoint

Represents a mutable point in two-dimensional Cartesian coordinates.
ImplementsInheritance Hierarchy

Members

Show:

Constructors

Creates the point with initial 0.0d values for x and y.
Creates an instance using the given coordinate pair.

Parameters

point: IPoint
The coordinate.
Creates an instance using the given coordinate pair.

Parameters

x: number
The x-coordinate
y: number
The y-coordinate

Properties

Gets or sets the x-coordinate.
final

Implements

IMutablePoint.x
Gets or sets the y-coordinate.
final

Implements

IMutablePoint.y

Methods

Create a clone of this object.
final

Return Value

Object
A clone of this object.
Calculates the Euclidean distance between two points.

Parameters

point2: IPoint
The second point.

Return Value

number
The distance between the two points.
Returns the euclidean distance between this point and a given point.

Parameters

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).
Determines whether another object is equal to this one.
final

Parameters

other: any
the other object to compare for equality

Return Value

boolean
true if other is considered equal to this instance.
Returns a hash code for this object.

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
Sets the x and y values of this instance to the given values.

Parameters

location: IPoint
The new location.
Sets the x and y values of this instance to the given values.

Parameters

x: number
The new x-coordinate.
y: number
The new y-coordinate.
Creates a new Point instance with the same coordinates as this point.
This 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

API
toMutablePoint

Defined in

IPoint.toPoint
Returns a that describes this instance.
final

Return Value

string
A that describes this instance.

Static Methods

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.
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)