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

x :number

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

y :number

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

box

Returns bounding box of a point
Source:

Methods

clone() → {Point}

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

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

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

rotate(angle, centeropt) → {Point}

Returns new point rotated by given angle around given center point. If center point is omitted, rotates around zero point (0,0). Positive value of angle defines rotation in counter clockwise direction, negative angle defines rotation in clockwise clockwise direction
Source:
Parameters:
Name Type Attributes Default Description
angle number angle in radians
center Point <optional>
(0,0) center
Returns:
Type:
Point

translate(vector) → {Point}

Returns new point translated by given vector. Translation vector may by also defined by a pair of numbers.
Source:
Parameters:
Name Type Description
vector Vector Translation vector defined as Flatten.Vector or
number | number Translation vector defined as pair of numbers
Returns:
Type:
Point

transform(m) → {Point}

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

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

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

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)

on(shape) → {boolean}

Returns true if point is on a shape, false otherwise
Source:
Parameters:
Name Type Description
shape Shape Shape of the one of supported types Point, Line, Circle, Segment, Arc, Polygon
Returns:
Type:
boolean

toJSON() → {Object}

This method returns an object that defines how data will be serialized when called JSON.stringify() method
Source:
Returns:
Type:
Object

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