documentationfor yFiles for HTML 2.6

Represents an immutable point in two-dimensional Cartesian coordinates with double precision.

Inheritance Hierarchy
Point
Implemented Interfaces

Remarks

In addition to being used to model points Point also includes a number of useful properties and methods that allow it to be treated as a vector.

Furthermore, Point provides various methods for analyzing and manipulating geometry in general, such as:

This is a convertible type that can be used with the following notation(s) in parameter lists, parameter objects or setters.

It is possible to specify an Object or plain Object to define the Point:

[5, 5] // x, y
{ x: 5, y: 5 }

Examples

The following example shows a few ways to use Point:
// Create a new point
const p1 = new Point(-5, 2)
// Create another point somewhere else
const p2 = new Point(23, 42)

console.log(
  `Point 1 is at (${p1.x},${p1.y}), point 2 is at (${p2.x},${p2.y})`
)

// Subtract one point from the other to get a vector between them
// which is also represented as a Point
const v = p2.subtract(p1)

// Point offers a few handy properties when interpreting it as a vector
console.log(`VectorLength: ${v.vectorLength}`)
// VectorLength in this case is equivalent to p1.distanceTo(p2):
console.log(`Distance: ${p1.distanceTo(p2)}`)

console.log(`IsHorizontalVector: ${v.isHorizontalVector}`)
console.log(`IsVerticalVector: ${v.isVerticalVector}`)
console.log(`Normalized: ${v.normalized}`)

const halfLength = v.multiply(0.2).vectorLength
const doubleLength = v.multiply(2).vectorLength

console.log(`Original vector: ${v.vectorLength}`)
console.log(`Half-length vector: ${halfLength}`)
console.log(`Double-length vector: ${doubleLength}`)

Type Details

yfiles module
view-component
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.geometry.Point

Constructors

Properties

Methods

Constants

Static Methods