Class el.Point
A pair of x,y coordinates.
Constructors
Point.new () | Create a new point with x and y = 0. |
Point.new (x, y) | Create a new point. |
Attributes
Point.x | X coord (number) |
Point.x | Y coord (number) |
Methods
Point:isOrigin () | True if is the origin point |
Point:isFinite () | True if is finite |
Point:withX (x) | Returns a point with the given x coordinate. |
Point:withY (y) | Returns a point with the given y coordinate. |
Point:setXY (x, y) | Set x and y at the same time. |
Point:addXY (x, y) | Adds a pair of coordinates to this value. |
Point:translated (deltax, deltay) | Move the point by delta x and y. |
Point:distance () | Distance to another point. |
Point:distanceSquared () | Distance from another point (squared). |
Point:angleTo (other) | Returns the angle from this point to another one. |
Point:rotated () | Get a rotated copy. |
Point:dotProduct () | Returns the dot product. |
Point:toInt () | Convert to integer values. |
Constructors
- Point.new ()
-
Create a new point with x and y = 0.
Returns:
- Point.new (x, y)
-
Create a new point.
Parameters:
- x number X coordinate
- y number Y coordinate
Returns:
Attributes
Methods
- Point:isOrigin ()
- True if is the origin point
- Point:isFinite ()
- True if is finite
- Point:withX (x)
-
Returns a point with the given x coordinate.
Parameters:
- x New x coord
Returns:
-
el.Point
New point object
- Point:withY (y)
-
Returns a point with the given y coordinate.
Parameters:
- y New y coord
Returns:
-
el.Point
New point object
- Point:setXY (x, y)
-
Set x and y at the same time.
Parameters:
- x number New x coordinate
- y number New y coordinate
- Point:addXY (x, y)
-
Adds a pair of coordinates to this value.
Parameters:
- x number X to add
- y number Y to add
- Point:translated (deltax, deltay)
-
Move the point by delta x and y.
Parameters:
- deltax number
- deltay number
- Point:distance ()
- Distance to another point.
- Point:distanceSquared ()
- Distance from another point (squared).
- Point:angleTo (other)
-
Returns the angle from this point to another one.
Taking this point to be the centre of a circle, and the other point being a position on the circumference, the return value is the number of radians clockwise from the 12 o'clock direction. So 12 o'clock = 0, 3 o'clock = Pi/2, 6 o'clock = Pi, 9 o'clock = -Pi/2
Parameters:
- other el.Point
- Point:rotated ()
-
Get a rotated copy.
Returns:
- Point:dotProduct ()
-
Returns the dot product.
Returns:
-
number
- Point:toInt ()
-
Convert to integer values.
Returns:
-
int