Creates a plane from a center point and x-axis.
The center of the plane.
The direction of the xAxis. If not specified, it will use Vector.worldX. The y-axis will be automatically generated perpendicular to this axis and will obey the right-hand rule.
Gets the point at the center of the plane.
Gets the plane's x-axis.
Remaps a point from the u-v space of the plane to the global coordinate system. This is the opposite of remapToPlaneSpace.
import { Plane, Point, Vector } from 'shapetypes'
// Create a plane
const plane = new Plane(new Point(3,4), Vector.worldX());
// Map a point from the global coordinate system to the plane's local coordinates
const worldPoint = new Point(5,6);
const planePoint = plane.remapToPlaneSpace(worldPoint);
console.log(planePoint.toString());
// => [2,2]
// Remap the local point back to the global coordinate system
const output = plane.pointAt(planePoint);
console.log(output.toString());
// => [5,6]
The location of the point measured as a distance along the plane's xAxis.
The location of the point measured as a distance along the plane's yAxis.
The u-v point remapped to the global coordinate system.
Remaps a point from the u-v space of the plane to the global coordinate system. This is the opposite of remapToPlaneSpace.
The u-v point remapped to the global coordinate system.
Gets the plane as a string in the format: [origin,xAxis]
.
Translates the geometry from one coordinate system to another while keeping
the geometry in the same position. In other words, if the geometry is currently
described relative to planeFrom
, after changeBasis,
it will be in the same position but described relative to planeTo
.
The coordinate system the geometry is currently described relative to.
The coordinate system to describe the geometry relative to.
The geometry in the new coordinate system.
Rotates the geometry about (0,0).
Angle to rotate the geometry (in radians). The direction is counter-clockwise.
Rotates the geometry about a point.
Angle to rotate the geometry (in radians). If the environment's y-axis points upwards, the direction is counter-clockwise.
Point to pivot the geometry about.
Scales the geometry and returns the resized geometry. The geometry will be scaled about (0,0), meaning everything will shrink or expand away from this point.
Magnitude to scale in x- and y-direction. If less than 1, the object will shrink. If greater than 1, it will grow.
Scales the geometry and returns the resized geometry. The geometry will be scaled about (0,0), meaning everything will shrink or expand away from this point.
Magnitude to scale in x-direction. If less than 1, the object will shrink. If greater than 1, it will grow.
Magnitude to scale in y-direction. If less than 1, the object will shrink. If greater than 1, it will grow.
Scales the geometry about a point and returns the resized geometry.
Magnitude to scale in x-direction. If less than 1, the object will shrink. If greater than 1, it will grow.
Magnitude to scale in y-direction. If less than 1, the object will shrink. If greater than 1, it will grow.
Center of scaling. Everything will shrink or expand away from this point.
Transforms the plane by a Transform matrix and returns the result.
import { Plane, Point, Transform, Vector } from 'shapetypes';
// Create a plane
const plane = new Plane(new Point(2,2), Vector.worldX());
console.log(plane.origin.toString());
// => (2,2)
// Translate using a transform matrix
const mover = Transform.translate(new Vector(3,4));
const moved = plane.transform(mover);
console.log(moved.origin.toString());
// => (5,6)
// Translate using the direct method
const otherMoved = plane.translate(new Vector(3,4));
console.log(otherMoved.origin.toString());
// => (5,6)
Moves the geometry along a vector and returns the moved geometry. The translation is always linear.
The direction and distance to move the geometry.
Moves the geometry along a vector and returns the moved geometry. The translation is always linear.
The direction to move the geometry.
The distance to move the geometry.
Generated using TypeDoc
A 2d frame with a center point (origin) and two perpendicular axes (xAxis and yAxis). The axes are always right-handed.
Example
import { Plane, Point, Vector } from 'shapetypes'; // Create a plane const plane = new Plane(new Point(3,4), Vector.worldX()); // Map a point from the global coordinate system to the plane's local coordinates const worldPoint = new Point(5,6); const planePoint = plane.remapToPlaneSpace(worldPoint); console.log(planePoint.toString()); // => [2,2] // Remap the local point back to the global coordinate system const output = plane.pointAt(planePoint); console.log(output.toString()); // => [5,6] // Translate the plane const moved = plane.translate(new Vector(10,20)); console.log(moved.origin.toString()); // => (13,24)