Point

Point

Class representing a point

Constructor

new Point(x, y)

Point may be constructed by two numbers, or by array of two numbers
Source:
Parameters:
Name Type Description
x number x-coordinate (float number)
y number y-coordinate (float number)

Classes

Point

Members

box

Returns bounding box of a point
Source:

x :number

x-coordinate (float number)
Source:
Type:
  • number

y :number

y-coordinate (float number)
Source:
Type:
  • number

Methods

clone() → {Point}

Return new cloned instance of point
Source:
Returns:
Type:
Point

distanceTo(shape) → {number|Segment}

Calculate distance and shortest segment from point to shape and return as array [distance, shortest segment]
Source:
Parameters:
Name Type Description
shape Shape Shape of the one of supported types Point, Line, Circle, Segment, Arc, Polygon or Planar Set
Returns:
  • Type:
    number
    distance from point to shape
  • Type:
    Segment
    shortest segment between point and shape (started at point, ended at shape)

equalTo(pt) → {boolean}

Returns true if points are equal up to Flatten.Utils.DP_TOL tolerance
Source:
Parameters:
Name Type Description
pt Point Query point
Returns:
Type:
boolean

leftTo(line) → {boolean}

Returns true if point belongs to the "left" semi-plane, which means, point belongs to the same semi plane where line normal vector points to Return false if point belongs to the "right" semi-plane or to the line itself
Source:
Parameters:
Name Type Description
line Line Query line
Returns:
Type:
boolean

lessThan(pt) → {boolean}

Defines predicate "less than" between points. Returns true if the point is less than query points, false otherwise
By definition point1 < point2 if {point1.y < point2.y || point1.y == point2.y && point1.x < point2.x
Numeric values compared with Flatten.Utils.DP_TOL tolerance
Source:
Parameters:
Name Type Description
pt Point Query point
Returns:
Type:
boolean

on(shape) → {boolean}

Returns true if point is on a shape, false otherwise
Source:
Parameters:
Name Type Description
shape Shape
Returns:
Type:
boolean

projectionOn(line) → {Point}

Returns projection point on given line
Source:
Parameters:
Name Type Description
line Line Line this point be projected on
Returns:
Type:
Point

svg(attrs) → {String}

Return string to draw point in svg as circle with radius "r"
Accept any valid attributes of svg elements as svg object Defaults attribues are:
{ r:"3", stroke:"black", strokeWidth:"1", fill:"red" }
Source:
Parameters:
Name Type Description
attrs Object Any valid attributes of svg circle element, like "r", "stroke", "strokeWidth", "fill"
Returns:
Type:
String

transform(m) → {Point}

Return new point transformed by affine transformation matrix
Source:
Parameters:
Name Type Description
m Matrix affine transformation matrix (a,b,c,d,tx,ty)
Returns:
Type:
Point