Represents a 2D Bézier curve.

Example:

import { QuadraticBezier, Vec2 } from '@js-draw/math';

const startPoint = Vec2.of(4, 3);
const controlPoint = Vec2.of(1, 1);
const endPoint = Vec2.of(1, 3);

const curve = new QuadraticBezier(
  startPoint,
  controlPoint,
  endPoint,
);

console.log('Curve:', curve);

Note: Some Bézier operations internally use the bezier-js library.

Hierarchy

Constructors

Properties

p0: Vec3

Start point

p1: Vec3

Control point

p2: Vec3

End point

Methods

  • Returns true if and only if the given point is contained within this shape.

    epsilon is a small number used to counteract floating point error. Thus, if point is within epsilon of the inside of this shape, containsPoint may also return true.

    The default implementation relies on signedDistance. Subclasses may override this method to provide a more efficient implementation.

    Parameters

    • point: Vec3
    • epsilon: number = Abstract2DShape.smallValue

    Returns boolean

  • Returns a bounding box that precisely fits the content of this shape.

    Note: This bounding box should aligned with the x/y axes. (Thus, it may be possible to find a tighter bounding box not axes-aligned).

    Returns Rect2

  • Parameters

    Returns {
        parameterValue: number;
        point: Vec3;
    }[]

  • Parameters

    Returns Vec3[]

    points at which this shape intersects the given lineSegment.

    If this is a closed shape, returns points where the given lineSegment intersects the boundary of this.

  • Returns the nearest point on this to point and the parameterValue at which that point occurs.

    Parameters

    Returns {
        parameterValue: number;
        point: Vec3;
    }

    • parameterValue: number
    • point: Vec3
  • Returns a string representation of an object.

    Returns string

OpenSource licenses