Point2D
From Emitrom
Point2D represents a 2-D point with (x,y) coordinates. It can also be used to represent a 2-D vector from (0,0) to (x,y).
Vector Math
The Point2D class provides several methods related to linear algebra, e.g.:
| Method | Meaning |
|---|---|
| plus | A + B |
| minus | A - B |
| times | f * A scalar times vector, i.e. (f * x, f * y) |
| div | A / f vector divided by scalar, i.e. (x/f, y/f) |
| getLength | |A| i.e. sqrt(x*x + y*y) |
| getAngle | angle between the positive X-axis and this vector |
| unit | Â a.k.a. normalized version of A same direction as A with length 1 |
| rotate(alpha) | rotates the vector alpha radians counter clockwise
|
| perpendicular | A' ⊥ A returns vector A' perpendicular to A (basically rotates A by 90 degrees counter clockwise) |
None of the above methods modify the Point2D object that the method is invoked on.
To modify a Point2D object in place (in situ) use one of these methods: plusInSitu, minusInSitu, timesInSitu, divInSitu, unitInSitu, rotateInSitu.
See also Transform
Point2DArray
Point2DArray represents an array of Point2D objects. It's a thin wrapper around a Javascript array.
