Class: Plane

Class representing a Plane.

A Plane defines an infinite flat surface in 3D space using an origin point and a normal direction. It's one of the most important coordinate system tools in BeeGraphy - you'll reach for it whenever you need to position, orient, or transform geometry relative to a specific frame of reference.

If you've used workplanes in other CAD tools, this is the same idea. A plane tells BeeGraphy "this is my local coordinate system" - where the origin is, which way is up, and how X and Y axes are oriented.

When to use Plane

  • Setting working planes - position geometry on a specific plane instead of the global XY
  • Coordinate transforms - convert between local and world coordinates with toLocalCoords() and toWorldCoords()
  • Mirror and symmetry - use a plane as the mirror reference
  • Sweep and extrude guides - define cross-section orientations along a path
  • Projecting points - find the closest point on a plane with closestPoint()
  • Plane-plane intersections - find where two planes meet with planePlane()
Ask AI about this page
ChatGPT

Quick start

// Create from origin + normal
const plane = Plane.byNormal(
  new Vector(0, 0, 0),   // origin
  new Vector(0, 0, 1)    // normal (pointing up = XY plane)
);

// Create from three points
const plane2 = Plane.by3Pnt(
  new Vector(0, 0, 0),
  new Vector(1, 0, 0),
  new Vector(0, 1, 0)
);

// Work with the plane
const origin = plane.origin();
const offsetPlane = plane.offset(10);       // move 10 units along normal
const flipped = plane.reverse(false, false, true); // swap X and Y axes

// Coordinate conversion
const localPt = plane.toLocalCoords(new Vector(5, 5, 5));
const worldPt = plane.toWorldCoords([1, 2, 0]);

// Find closest point on the plane
const result = plane.closestPoint(new Vector(3, 4, 7));
// result.point, result.distance, result.uvPoint

Key methods at a glance

MethodWhat it does
origin()Get the plane's origin point
setOrigin(v)Move the plane to a new origin
adjust(normal)Reorient the plane with a new normal
offset(distance)Shift the plane along its normal
reverse(x, y, swap)Flip or swap the plane's axes
clone()Create an independent copy
closestPoint(v)Nearest point on the plane to a given point
toLocalCoords(v)World vector to plane-local coordinates
toWorldCoords(v)Plane-local coordinates to world vector
align(direction)Align the plane to a direction
planePlane(plane)Intersection line between two planes
Plane.byNormal(o, n)Create from origin + normal (static)
Plane.by3Pnt(o, a, b)Create from three points (static)

Method: constructor

Create a Plane.

Parameters

  • origin (Point): The origin point of the plane.

Example

const origin = new Vector(0, 0, 0);
const instance = new Plane();
instance.constructor(origin);

Method: plane

Get the plane.

Returns

The plane.

Example

const instance = new Plane();
instance.plane();

Method: plane

Set the plane.

Parameters

  • plane: The new plane.

Example

const instance = new Plane();
instance.plane(plane);

Method: type

Get the type of the plane.

Returns

The type of the curve.

Example

const instance = new Plane();
instance.type();

Method: delete

Deletes the plane and performs necessary cleanup operations.

Example

const instance = new Plane();
instance.delete();

Method: clone

Clone the plane.

Returns

A new plane instance.

Example

const instance = new Plane();
instance.clone();

Method: origin

Get the origin of the plane.

Returns

The origin of the plane.

Example

const instance = new Plane();
instance.origin();

Method: setOrigin

Set the origin of the plane.

Parameters

  • newOrigin (IVector): The new origin of the plane.

Example

const newOrigin = new Vector(1, 1, 1);
const instance = new Plane();
instance.setOrigin(newOrigin);

Method: setOrigin2d

Set the origin of the plane in 2D.

Parameters

  • x (number): The x coordinate.
  • y (number): The y coordinate.

Example

const x = 0.5;
const y = 0.5;
const instance = new Plane();
instance.setOrigin2d(x, y);

Method: adjust

Adjust the plane with a new normal.

Parameters

  • newNormal (IVector): The new normal vector.

Returns

A new plane instance.

Example

const newNormal = new Vector(1, 1, 1);
const instance = new Plane();
instance.adjust(newNormal);

Static Method: by3Pnt

Create a plane by three points.

Parameters

  • origin (IVector): The origin point.
  • pointA (IVector): The first point.
  • pointB (IVector): The second point.

Returns

A new plane instance.

Example

const origin = new Vector(1, 1, 1);
const pointA = new Vector(0, 0, 0);
const pointB = new Vector(1, 1, 1);
Plane.by3Pnt(origin, pointA, pointB);

Static Method: byLinePnt

Create a plane by a line and a point.

Parameters

  • line (ICurve): The line.
  • point (IVector): The point.

Returns

A new plane instance.

Example

const line = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const point = new Vector(1, 1, 1);
Plane.byLinePnt(line, point);

Static Method: by2Line

Create a plane by two lines.

Parameters

  • lineA (Curve): The first line.
  • lineB (Curve): The second line.

Returns

A new plane instance.

Example

const lineA = /* specify a lineA */;
const lineB = /* specify a lineB */;
Plane.by2Line(lineA, lineB);

Static Method: byNormal

Create a plane by a normal vector.

Parameters

  • origin (Vector): The origin point.
  • normal (Vector): The normal vector.

Returns

A new plane instance.

Example

const origin = /* specify a origin */;
const normal = /* specify a normal */;
Plane.byNormal(origin, normal);

Method: dump

Dump the plane information.

Returns

The plane information.

Example

const instance = new Plane();
instance.dump();

Method: reverse

Reverse the plane directions.

Parameters

  • xFlip (boolean): Whether to flip the x direction.
  • yFlip (boolean): Whether to flip the y direction.
  • swap (boolean): Whether to swap the x and y directions.

Returns

A new plane instance.

Example

const xFlip = /* specify a xFlip */;
const yFlip = /* specify a yFlip */;
const swap = /* specify a swap */;
const instance = new Plane();
instance.reverse(xFlip, yFlip, swap);

Method: offset

Offset the plane by a distance.

Parameters

  • distance (number): The distance to offset.

Returns

A new plane instance.

Example

const distance = 0.5;
const instance = new Plane();
instance.offset(distance);

Method: closestPoint

Find the closest point on the plane to a given point.

Parameters

  • point (Vector): The point.

Returns

The closest point, distance, and UV point.

Example

const point = /* specify a point */;
const instance = new Plane();
instance.closestPoint(point);

Method: align

Align the plane to a direction.

Parameters

  • direction (IVector): The direction to align to.

Returns

The aligned plane and angle.

Example

const direction = new Vector(1, 1, 1);
const instance = new Plane();
instance.align(direction);

Method: toLocalCoords

Convert a vector to local coordinates.

Parameters

  • vec (IVector): The vector.

Returns

The vector in local coordinates.

Example

const vec = new Vector(1, 1, 1);
const instance = new Plane();
instance.toLocalCoords(vec);

Method: toWorldCoords

Convert a point to world coordinates.

Parameters

  • v (Point): The point.

Returns

The point in world coordinates.

Example

const v = /* specify a v */;
const instance = new Plane();
instance.toWorldCoords(v);

Method: planePlane

Project a plane to another plane.

Parameters

  • plane : The plane to project to.

Returns

The intersection line between the two planes.

Example

const plane = /* specify a plane */;
const instance = new Plane();
instance.planePlane(plane);