An extension class for h2d.col.Point.

Available since

0.1.0

.

See also:

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 h2d.col.Point instances to sort.

p

An h2d.col.Point instance to sort array with.

dir

An h2d.col.Point instance that defines a direction. Default direction is (0,-1), up.

Returns:

The now sorted array, array.

@:value({ epsilon : 0.00000000001 })staticinlineequalEps(p1:Point, p2:Point, epsilon:Float = 0.00000000001):Bool

Checks equality between two points with a tolerance value.

Parameters:

p1

The first point.

p2

The second point.

epsilon

The tolerance value.

Returns:

true if there is an equality, false otherwise.

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 h2d.col.Point instance to round.

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 h2d.col.Point.

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 h2d.col.Point instance.

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 h2d.col.Point instance.

o

The h2d.Object instance the new point should be relative to.

parent

The h2d.Object instance p's position is relative to. If null, p is assumed to be a global coordinate.

Returns:

A new h2d.col.Point instance relative to o.