Autodesk Creative Platform Core Version 1.19.0
A broad and deep collection of 2D and 3D capabilities.

Point2D Overview

Implements Interfaces: IDebuggable

A point in 2D Space.

Introduced in Version: 1.1.0

Class Member Summary

Class Member Details

• Point2D (x, y) | Constructor

The following parameters can be specified in the constructor:
  • x: Number - The X component of the point.
  • y: Number - The Y component of the point.

Point2D clone()

Creates a copy of the object and returns it.

• debug()

Instructs the object to present useful debugging information via a series of calls to Debug.point, Debug.line and Debug.triangles.

Number distanceTo (point)

Calculates the distance to another point

Boolean equals (other)

Returns true if the objects are equal within tolerance (1e-6), otherwise false.
  • other: Point2D or Object - An object to compare this object to.

Point2D move (direction, [y]) | Chainable

Moves the point in the direction specified.
  • direction: Vector2D or Number or Array [ Number ] - A direction of movement defined by a Vector2D, an Array with 2 values (X and Y), or a number representing the X offset.
  • y: Number - The Y offset to move in, when only the X offset is specified as the first argument. | Optional

3 Examples:

// Move the point by given a Vector2D object
var vec = new Vector2D(-1, -1);
point.move(vec);
// Move the point by given a 2-element array
var arr = [-1, -1];
point.move(arr);
// Move the point by given x, y offsets
var xoffset = -1,
    yoffset = -1;
point.move(xoffset, yoffset);

Point2D rotate (angle, [origin], [y]) | Chainable

Rotates the point around an optionally specified point. If no origin is specified then 0,0 is assumed. Right-handed system is used implying the positive angles result in counter-clockwise orientations.
  • angle: Number - The angle of rotation in radians
  • origin: Point2D or Number or Array [ Number ] - An optional origin of rotation defined by a Point2D, an Array with 2 values (X and Y), or a number representing the X value. | Optional
  • y: Number - The Y position to rotate around, when only the X offset is specified in the previous argument. | Optional

3 Examples:

// Rotate the point by given angle around the default 0,0 point as origin
point.rotate(Math.PI/2);
// Rotate the point by given angle and the origin specified in a 2-element array
point.rotate(Math.PI/2, [1, 1]);
// Rotate the point by given angle and the origin specified in the 2nd and 3rd arguments
point.rotate(Math.PI/2, 1, 1);

Point2D scale (scale, [y]) | Chainable

Scales the location of the point.
  • scale: Vector2D or Array [ Number ] or Number - A scale defined by a Vector2D, an Array with 2 values (X and Y), or a number representing the X scale (and Y scale if no additional parameter is specified.)
  • y: Number - An option Y scale to use if an X scale was specified as the first argument. If this argument is not specified then uniform scaling is assumed. | Optional

4 Examples:

// Scale the point by given one scale number uniformly
point.scale(0.5);
// Scale the point by given X and Y scale numbers
point.scale(0.5, 0.75);
// Scale the point by given a Vector2D object
var vec = new Vector2D(0.5, 0.75);
point.scale(vec);
// Scale the point by given a 2-element array with X and Y scale numbers
point.scale([0.5, 0.75]);

Point2D transform (matrix) | Chainable

Transforms the point by a transformation matrix.

2 Examples:

// Transform the point (x, y) by given a 9-element array 
tm = [a, b, 0, c, d, 0, e, f, 1] representing following matrix
[a b 0] 
[c d 0]
[e f 1]  
new coordinates would be (a*x + c*y + e, b*x + d*y + f)

point.transform(tm);
// Transform the point by given a Matrix2D object
point.transform(tm);

Number x

The X position of the point

Number y

The Y position of the point