lights FAQ Forum github.com/luapower/path2d

2D Graphics
path2d
affine2d
box2d
clipper
cairo
freetype
openvg
svg_parser
hpdf

path2d_point

basic math for the cartesian plane


local point = require'path2d_point'

Basic math functions for the cartesian plane. Angles are expressed in degrees, not radians.

point.hypot(a, b) -> c

Hypotenuse function: computes sqrt(a^2 + b^2) without underflow / overflow problems.

point.distance(x1, y1, x2, y2) -> d

Dstance between two points.

point.distance2(x1, y1, x2, y2) -> d2

Distance between two points squared.

point.point_around(cx, cy, r, angle) -> x, y

Point at a specified angle on a circle.

point.rotate_point(x, y, cx, cy, angle) -> x, y

Eotate point (x,y) around origin (cx,cy) by angle.

point.point_angle(x, y, cx, cy) -> angle

Angle between two points in -180..180 degree range.

point.reflect_point(x, y, cx, cy) -> x, y

Reflect point through origin (i.e. rotate point 180deg around another point).

point.reflect_point_distance(x, y, cx, cy, length) -> x, y

Reflect point through origin at a specified distance.


Last updated: 2 months ago | Edit on GitHub

Pkg type:Lua+ffi
Version: dev-30-gd1027f3
Last commit:
License: PD
Requires: eq  glue  pp  vararg  luajit 
Required by: sg  cplayer  winapi 

Top