class PointExt
package nb.ext
Static methods
staticclockwiseSort(array:Array<Point>, p:Point, ?dir:Point):Array<Point>
Sorts an array of points depending on their position relative to a point, in a clockwise manner.
Example :
Imagine an analog clock where p is at the center and array is an array of points
where each point is at one of the 12 numbers on the clock ([p1,p2,...,p12]).
The result with dir being the direction from the center to :
- p12, which is (0,-1), is [p12,p1,p2,...,p11].
- p3, which is (1,0), is [p3,p4,...,p12,p1,p2].
- p6, which is (0,1), is [p6,p7,...,p12,p1,...,p5].
- p9, which is (-1,0), is [p9,p10,...,p12,p1,...,p8].
Parameters:
array | An array of |
|---|---|
p | An |
dir | An |
Returns:
The now sorted array, array.
staticinlinefloor(p:Point):Point
Returns the copy of a point with each of its coordinate rounded to the closest integer not greater than the coordinate.
Parameters:
p | An |
|---|
Returns:
A rounded copy of p.
staticgetFarthestPoints(points:Array<Point>, direction:Point):Array<Point>
Returns the farthest point in a given direction.
Parameters:
points | An array of |
|---|---|
direction | Defines a direction where (1,0) is right and (0,1) is down. |
Returns:
The farthest point in the array. (No copy is done.)
staticinlinemoveTowards(p:Point, angle:Float, distance:Float):Point
Moves a point towards a direction defined by an angle.
Parameters:
p | An |
|---|---|
angle | An angle in radians. |
distance | The distance to move from. |
Returns:
The now moved point, p.
staticinlinerelativeTo(p:Point, o:Object, ?parent:Object):Point
Given a point relative to an object's position, returns the associated point relative to another object's position.
Parameters:
p | An |
|---|---|
o | The |
parent | The |
Returns:
A new h2d.col.Point instance relative to o.