Class: Curve

Class representing a Curve.

A Curve is any piece of 1D geometry - lines, arcs, circles, splines, polylines, or complex wire shapes made from multiple segments joined together. Curves are one of the three core geometry types in BeeGraphy (alongside Surface and Solid), and they inherit common operations from Geometry.

In practice, you'll use curves constantly. They're the starting point for most 3D modeling workflows: draw a profile, then extrude, sweep, revolve, or loft it into a solid.

When to use Curve

  • Creating profiles - draw the cross-section shape for extrusions and sweeps
  • Defining paths - guide sweeps, arrays, and lofts along a curve
  • Building boundaries - outline regions for surfaces or trimming operations
  • Measuring and dividing - get curve length, divide into equal segments, find points along the path
  • Boolean operations - union, intersection, and difference of 2D shapes
  • Intersections - find where curves cross other curves, surfaces, or solids
Ask AI about this page
ChatGPT

Quick start

// Create curves with CurveBuilder
const line = CurveBuilder.line(new Vector(0, 0, 0), new Vector(10, 0, 0));
const circle = CurveBuilder.circle(new Vector(0, 0, 0), 5);
const arc = CurveBuilder.arc(new Vector(0, 0, 0), new Vector(5, 0, 0), new Vector(0, 5, 0));

// Query the curve
const length = line.curveLength();
const start = line.startPoint();
const end = line.endPoint();
const closed = circle.isClosed(); // true

// Divide into points along the curve
const { points, tangents } = circle.divideByCount(12);

// Extrude into a surface
const surface = circle.extrude(new Vector(0, 0, 10));

// Boolean operations on closed curves
const combined = circle.union([otherCurve]);
const trimmed = circle.difference([otherCurve]);

// Find intersections
const hits = line.intersectCurve(circle);

Key methods at a glance

MethodWhat it does
curveLength()Total length of the curve
startPoint(), endPoint()First and last points
isClosed()Whether the curve forms a loop
pointOnCurve(t)Point at parameter t (0 to 1)
evaluateCurve(t)Point + derivatives at parameter t
divideByCount(n)Split into n equal segments
divideByDistance(d)Split by fixed step distance
closestPoint(v)Nearest point on curve to a given point
extrude(dir)Extrude into a surface
offset(size, side)Offset the curve
union(geoms)Boolean union with other geometry
intersection(geoms)Boolean intersection
difference(geoms)Boolean subtraction
explode(recursive)Break into individual segments
flip()Reverse the curve direction
bBox()Bounding box (width, height, area, center)
perpPlane(t)Perpendicular plane at parameter t
Curve.join(curves)Join multiple curves (static)

Method: wires

Gets the wires of the curve.

Example

const instance = new Curve();
instance.wires();

Method: type

Gets the type of the curve.

Returns

The type of the curve.

Example

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

Method: edges

Gets the edges of the curve.

Example

const instance = new Curve();
instance.edges();

Method: getWires

Gets the wires of the curve.

Returns

An array of wires.

Example

const instance = new Curve();
instance.getWires();

Method: getFace

Gets the face of the curve.

Returns

The face of the curve.

Example

const instance = new Curve();
instance.getFace();

Method: createFaceFromWire

Creates a face from a wire.

Parameters

  • wire (TopoDS_Wire): The wire to create the face from.

Returns

The created face.

Example

const wire = /* specify a wire */;
const instance = new Curve();
instance.createFaceFromWire(wire);

Method: sortWiresByVolume

Sorts wires by area.

Parameters

  • wires (TopoDS_Wire[]): The wires to sort.

Returns

An array of sorted wires with their areas.

Example

const wires = /* specify a wires */;
const instance = new Curve();
instance.sortWiresByVolume(wires);

Method: getEdges

Gets the edges of the curve.

Returns

An array of edges.

Example

const instance = new Curve();
instance.getEdges();

Method: curveLength

Gets the length of the curve.

Returns

The length of the curve.

Example

const instance = new Curve();
instance.curveLength();

Method: faceNormal

Gets the normal of the face.

Returns

The normal vector.

Example

const instance = new Curve();
instance.faceNormal();

Method: lengthParameter

Gets the length parameters.

Parameters

  • t (number): The parameter value.

Returns

An object containing length1(Length from the start to t) and length2(Length from t to the end).

Example

const t = 0.5;
const instance = new Curve();
instance.lengthParameter(t);

Static Method: render

Renders the wire with the given tolerance.

Parameters

  • wire (TopoDS_Wire): The wire to render.
  • tolerance (number): The tolerance value.

Returns

An array of points.

Example

const wire = /* specify a wire */;
const tolerance = 0.5;
Curve.render(wire, tolerance);

Method: offset

Offsets the curve.

Parameters

  • offsetSize (number): The size of the offset.
  • side (boolean): The side of the offset.
  • offsetType (OffsetType = OffsetType.Arc): The type of the offset.

Returns

The offset curve.

Example

const offsetSize = 0.5;
const side = /* specify a side */;
const offsetType = /* specify a offsetType */;
const instance = new Curve();
instance.offset(offsetSize, side, offsetType);

Method: isCircle

Checks if the curve is a circle.

Returns

True if the curve is a circle, false otherwise.

Example

const instance = new Curve();
instance.isCircle();

Method: isArc

Checks if the curve is an arc.

Returns

True if the curve is an arc, false otherwise.

Example

const instance = new Curve();
instance.isArc();

Method: isLine

Checks if the curve is a line.

Returns

True if the curve is a line, false otherwise.

Example

const instance = new Curve();
instance.isLine();

Method: isRectangle

Checks if the curve is a rectangle.

Returns

True if the curve is a rectangle, false otherwise.

Example

const instance = new Curve();
instance.isRectangle();

Method: isPlanar

Checks if the curve is planar.

Returns

An object containing isPlaner, plane, and distance.

Example

const instance = new Curve();
instance.isPlanar();

Method: chamfer

Chamfers the curve.

Parameters

  • distance1 (number): The first distance for chamfer.
  • distance2 (number): The second distance for chamfer.

Returns

The chamfered curve.

Example

const distance1 = 0.5;
const distance2 = 0.5;
const instance = new Curve();
instance.chamfer(distance1, distance2);

Method: discontinuity

Gets the discontinuities in the curve.

Returns

An array of points representing the discontinuities.

Example

const instance = new Curve();
instance.discontinuity();

Method: extrude

Extrudes the curve in the given direction.

Parameters

  • direction (IVector): The direction vector.

Returns

The extruded surface.

Example

const direction = new Vector(1, 1, 1);
const instance = new Curve();
instance.extrude(direction);

Static Method: join

Joins multiple curves.

Parameters

  • curves (ICurve[]): The curves to join.

Returns

An array of joined curves.

Example

const curves = /* specify a curves */;
Curve.join(curves);

Method: explode

Explodes the curve.

Parameters

  • recursive (boolean): Whether to explode recursively.

Returns

An object containing segments and points.

Example

const recursive = /* specify a recursive */;
const instance = new Curve();
instance.explode(recursive);

Method: divideByLength

Divides the curve by length.

Parameters

  • length (number): The length to divide by.

Returns

An object containing points, tangents, and parameters.

Example

const length = 10;
const instance = new Curve();
instance.divideByLength(length);

Method: divideByDistance

Divides the curve by distance.

Parameters

  • step (number): The distance to divide by.

Returns

An object containing points, tangents, and parameters.

Example

const step = 0.5;
const instance = new Curve();
instance.divideByDistance(step);

Method: divideByCount

Divides the curve by count.

Parameters

  • count (number): The number of divisions.

Returns

An object containing points, tangents, and parameters.

Example

const count = 0.5;
const instance = new Curve();
instance.divideByCount(count);

Method: contour

Gets the contour of the curve.

Parameters

  • point (IVector): The point vector.
  • direction (IVector): The direction vector.
  • distance (number): The distance.

Returns

An array of points representing the contour.

Example

const point = new Vector(1, 1, 1);
const direction = new Vector(1, 1, 1);
const distance = 0.5;
const instance = new Curve();
instance.contour(point, direction, distance);

Method: getDividedSegments

Gets the divided segments of the curve.

Parameters

  • points (IVector[]): The points to divide by.

Returns

An array of segments.

Example

const points = /* specify a points */;
const instance = new Curve();
instance.getDividedSegments(points);

Method: startPoint

Gets the start point of the curve.

Returns

The start point vector.

Example

const instance = new Curve();
instance.startPoint();

Method: endPoint

Gets the end point of the curve.

Returns

The end point vector.

Example

const instance = new Curve();
instance.endPoint();

Method: seam

Seams the curve.

Parameters

  • t (number): The parameter value.

Returns

The seamed curve.

Example

const t = 0.5;
const instance = new Curve();
instance.seam(t);

Method: pointOnCurve

Gets the point on the curve.

Parameters

  • t (number): The parameter value.

Returns

The point vector.

Example

const t = 0.5;
const instance = new Curve();
instance.pointOnCurve(t);

Method: evaluateCurve

Evaluates the curve.

Parameters

  • parameter (number): The parameter value.
  • byLength (boolean): Whether to evaluate by length.

Returns

An object containing point, vector1(first derivatives), and vector2(second derivatives).

Example

const parameter = 0.5;
const byLength = /* specify a byLength */;
const instance = new Curve();
instance.evaluateCurve(parameter, byLength);

Method: pointInCurve

Checks if a point is in the curve.

Parameters

  • point (IVector): The point vector.

Returns

An object containing projectPoint and relationship.

Example

const point = new Vector(1, 1, 1);
const instance = new Curve();
instance.pointInCurve(point);

Method: controlPoints

Gets the control points of the curve.

Returns

An object containing points, knots, weights, and multiplicities.

Example

const instance = new Curve();
instance.controlPoints();

Method: closestPoint

Gets the closest point on the curve.

Parameters

  • point (IVector): The point vector.

Returns

An object containing nearest and pointsArr.

Example

const point = new Vector(1, 1, 1);
const instance = new Curve();
instance.closestPoint(point);

Method: bBox

Gets the bounding box of the curve.

Returns

An object containing width, length, height, area, center, and boundingBox.

Example

const instance = new Curve();
instance.bBox();

Method: flip

Flips the curve.

Returns

The flipped curve.

Example

const instance = new Curve();
instance.flip();

Method: area

Gets the area of the curve.

Returns

The area of the curve.

Example

const instance = new Curve();
instance.area();

Method: isClosed

Checks if the curve is closed.

Returns

True if the curve is closed, false otherwise.

Example

const instance = new Curve();
instance.isClosed();

Method: deconstructArc

Deconstructs the arc.

Returns

An object containing plane, radius, startAngle, and endAngle.

Example

const instance = new Curve();
instance.deconstructArc();

Method: union

Unions the curve with other curves.

Parameters

  • geometries ((ICurve | ISurface | ISolid): The curves to union with.

Returns

The unioned curve.

Example

const geometries = /* specify a geometries */;
const instance = new Curve();
instance.union(geometries);

Method: intersection

Intersects the curve with other curves.

Parameters

  • geometries (IGeometry[]): The curves to intersect with.

Returns

An array of intersection curves.

Example

const geometries = /* specify a geometries */;
const instance = new Curve();
instance.intersection(geometries);

Method: difference

Gets the difference between the curve and other curves.

Parameters

  • geometries (IGeometry[]): The curves to subtract.

Returns

The resulting curve.

Example

const geometries = /* specify a geometries */;
const instance = new Curve();
instance.difference(geometries);

Method: Unknown

Creates an array of geometry along a curve.

Parameters

  • geometry (IGeometry[]): The geometry to array.
  • count (number): The number of elements in the array.

Returns

An array of geometries.

Method: intersectCurve

Intersects the curve with another curve.

Parameters

  • curve (ICurve): The curve to intersect with.

Returns

An array of intersection points.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const instance = new Curve();
instance.intersectCurve(curve);

Method: intersectSurface

Intersects the curve with a surface.

Parameters

  • surface (ISurface): The surface to intersect with.

Returns

An array of intersection points.

Example

const surface = /* specify a surface */;
const instance = new Curve();
instance.intersectSurface(surface);

Method: intersectSolid

Intersects the solid with a curve.

Parameters

  • solid (ISolid): The solid to intersect with.

Returns

An array of intersection points.

Example

const solid = /* specify a solid */;
const instance = new Curve();
instance.intersectSolid(solid);

Method: solidCurve

Intersects the solid with a curve.

Parameters

  • solid (ISolid): The solid to intersect with.

Returns

An array of intersection overlap curves.

Example

const solid = /* specify a solid */;
const instance = new Curve();
instance.solidCurve(solid);

Method: selfIntersect

Checks for self-intersections in the curve.

Returns

An array of self-intersection points.

Example

const instance = new Curve();
instance.selfIntersect();

Method: rebuildCurve

Rebuilds the curve with the given degree.

Parameters

  • degree (number): The degree of the curve.

Returns

The rebuilt curve.

Example

const degree = 0.5;
const instance = new Curve();
instance.rebuildCurve(degree);

Method: mirrorByCurve

Mirrors the curve by another curve.

Parameters

  • curve (ICurve): The curve to mirror by.

Returns

The mirrored curve.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const instance = new Curve();
instance.mirrorByCurve(curve);

Method: curveToPolyline

Converts the curve to a polyline.

Parameters

  • toleranceDist (number): The tolerance distance.
  • edge (number): The edge length.

Returns

The polyline curve.

Example

const toleranceDist = 0.5;
const edge = 0.5;
const instance = new Curve();
instance.curveToPolyline(toleranceDist, edge);

Method: perpPlane

Gets the perpendicular plane at the given parameter.

Parameters

  • parameter (number): The parameter value.

Returns

The perpendicular plane.

Example

const parameter = 0.5;
const instance = new Curve();
instance.perpPlane(parameter);

Method: perpPlanes

Gets the perpendicular planes.

Parameters

  • count (number): The number of planes.
  • align (boolean): Whether to align the planes.

Returns

An object containing planes and parameters.

Example

const count = 0.5;
const align = /* specify a align */;
const instance = new Curve();
instance.perpPlanes(count, align);

Method: horizontalPlane

Gets the horizontal plane at the given parameter.

Parameters

  • parameter (number): The parameter value.

Returns

The horizontal plane.

Example

const parameter = 0.5;
const instance = new Curve();
instance.horizontalPlane(parameter);

Method: horizontalPlanes

Gets the horizontal planes.

Parameters

  • count (number): The number of planes.
  • align (boolean): Whether to align the planes.

Returns

An object containing planes and parameters.

Example

const count = 0.5;
const align = /* specify a align */;
const instance = new Curve();
instance.horizontalPlanes(count, align);

Method: curvePlane

Gets the curve plane at the given parameter.

Parameters

  • parameter (number): The parameter value.

Returns

The curve plane.

Example

const parameter = 0.5;
const instance = new Curve();
instance.curvePlane(parameter);

Method: curvePlanes

Gets the curve planes.

Parameters

  • count (number): The number of planes.

Returns

An object containing planes and parameters.

Example

const count = 0.5;
const instance = new Curve();
instance.curvePlanes(count);

Method: dashPattern

Creates a dash pattern on the curve.

Parameters

  • pattern (number[]): The dash pattern.

Returns

An object containing dashes and gaps.

Example

const pattern = /* specify a pattern */;
const instance = new Curve();
instance.dashPattern(pattern);

Method: tween

Tweens the curve with another curve.

Parameters

  • curve (ICurve): The curve to tween with.
  • parameter (number): The parameter value.

Returns

The tweened curve.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const parameter = 0.5;
const instance = new Curve();
instance.tween(curve, parameter);

Method: proximity

Checks the proximity between the curve and another curve.

Parameters

  • curve (ICurve): The curve to check proximity with.

Returns

An object containing pointA, pointB, and distance.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const instance = new Curve();
instance.proximity(curve);

Method: extremes

Gets the extremes of the curve.

Parameters

  • plane (IPlane): The plane to get extremes on.

Returns

An object containing highest and lowest points.

Example

const plane = /* specify a plane */;
const instance = new Curve();
instance.extremes(plane);

Method: centerOfMass

Gets the center of mass of the curve.

Returns

The center of mass point vector.

Example

const instance = new Curve();
instance.centerOfMass();

Method: projectCurve

Projects the curve onto a geometry.

Parameters

  • geometry (IGeometry): The geometry to project onto.
  • direction (IVector): The direction vector.

Returns

An array of projected curves.

Example

const geometry = /* specify a geometry */;
const direction = new Vector(1, 1, 1);
const instance = new Curve();
instance.projectCurve(geometry, direction);

Method: cullCurves

Culls duplicate curves.

Parameters

  • curves (ICurve[]): The curves to cull.

Returns

An object containing culledCurves and duplicateIndexes.

Example

const curves = /* specify a curves */;
const instance = new Curve();
instance.cullCurves(curves);

Method: isEquivalentCurve

Checks if two curves are equivalent.

Parameters

  • curve (ICurve): No description

Returns

True if the curves are equivalent, false otherwise.

Example

const curve = CurveBuilder.line(new Vector(0, 0, 0), new Vector(1, 1, 1));
const instance = new Curve();
instance.isEquivalentCurve(curve);

Method: dump

Dumps the details of the curve.

Example

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