point2line
This lightweight Processing/Java library contains basic tools for calculating geometry in two dimensions. It includes a vector class that offers an alternative to the build in PVector class. The library only adds functions that I either miss in the existing collection of libraries or think could be simplified.

Vect2 stores and manipulates vectors and positions in 2D.
Space2 serves as a toolbox for geometry calculations in 2D.

The library does not depend on other libraries and should be able to run on most Processing versions and all OS platforms (please report problems).

DOWNLOAD

RELEASE 06. UPDATED THE JULY 23RD 2013
http://sixthsensor.dk/code/p5/point2line/download/point2line.zip

Read the revisions.

EXAMPLES

Living Net

ABOUT

The library has been under development since 2005 and and it still is. It will be kept slim and basic. It was originally created for my personal design projects but is now used for my teaching purposes as well. Suggestions concerning optimisations and extensions are most welcome. The library is free software; you can redistribute it and/or modify it for any desirable purpose. It is distributed in the hope that it will be useful, but without any warranty.


Carl Emil Carlsen
2008+

Vect2


properties

x
y
isZero ( )
isAlmostZero ( )
equals ( )

basic math

add ( )
added ( )
subtract ( )
subtracted ( )
scale ( )
scaled ( )
divide ( )
divided ( )

magnitude

magnitude ( )
setMagnitude ( )
normalize ( )
normalized ( )
clip ( )
clipped ( )
isGreaterThan ( )
isLessThan ( )
squareMagnitude ( )

rotation

angle ( )
rotate ( )
rotated ( )
setRotation ( )
rotateLeft ( )
rotatedLeft ( )
rotateRight ( )
rotatedRight ( )
flip ( )
flipped ( )
rotateAround ( )
rotatedAround ( )

helpers

set ( )
setZero ( )
clone ( )
toString ( )

static tools

lerp ( )
distance ( )
dot ( )
angleBetween ( )
angleBetweenUnits ( )
angleFromTo ( )
midpoint ( )


Space2


static tools

ellipsePoint ( )
insidePolygon ( )
pointToLineDistance ( )
closestPointToLine ( )
closestPointOnLine ( )
closestPointOnLineSegment ( )
lineIntersection ( )
lineSegmentIntersection ( )
Vect2

Vect2
HALF_PI
PI
QUARTER_PI
TWO_PI
x
y
add ( )
added ( )
angle ( )
angleBetween ( )
angleBetweenUnits ( )
angleFromTo ( )
clip ( )
clipped ( )
clone ( )
copy ( )
distance ( )
divide ( )
divided ( )
dot ( )
equals ( )
flip ( )
flipped ( )
isAlmostZero ( )
isGreaterThan ( )
isLessThan ( )
isZero ( )
lerp ( )
magnitude ( )
midpoint ( )
normalize ( )
normalized ( )
rotate ( )
rotateAround ( )
rotateLeft ( )
rotateRight ( )
rotated ( )
rotatedAround ( )
rotatedLeft ( )
rotatedRight ( )
scale ( )
scaled ( )
set ( )
setMagnitude ( )
setRotation ( )
setZero ( )
squareMagnitude ( )
subtract ( )
subtracted ( )
toString ( )

Space2

Space2
closestPointOnLine ( )
closestPointOnLineSegment ( )
closestPointToLine ( )
ellipsePoint ( )
insidePolygon ( )
lineIntersection ( )
lineSegmentIntersection ( )
pointToLineDistance ( )