Skip to content

compas_brep.curves.nurbs ¤

This is an attempt at Pure-Python rational NURBS curve built on scipy.interpolate.BSpline.

This is a replacement for the compas.geometry.NurbsCurve pluggable but need to be evaluated for completness.

Classes¤

NurbsCurve ¤

NurbsCurve(name: str | None = None)

A rational NURBS curve.

Parameters:

  • name (str | None, default: None ) –

    The name of the curve.

Attributes¤

degree property ¤
degree: int

Degree of the curve.

domain property ¤
domain: tuple[float, float]

Parameter domain of the curve.

is_closed property ¤
is_closed: bool

True if the first and last control points coincide.

is_periodic property ¤
is_periodic: bool

Always False (simplified).

knots property ¤
knots: list[float]

Unique knot values.

knotvector property ¤
knotvector: list[float]

Full knot vector (knots repeated by multiplicities).

mults property ¤
mults: list[int]

Knot multiplicities.

points property ¤
points: list[Point]

Control points.

weights property ¤
weights: list[float]

Weights.

Methods:¤

copy ¤
copy() -> NurbsCurve

Return a deep copy.

frame_at ¤
frame_at(t: float) -> Frame

Frame at parameter t.

Parameters:

  • t (float) –

    Parameter value.

from_circle classmethod ¤
from_circle(circle: Circle) -> NurbsCurve

Create a rational NURBS circle (degree 2, 9 control points).

Parameters:

  • circle (Circle) –

    The circle.

from_ellipse classmethod ¤
from_ellipse(ellipse: Ellipse) -> NurbsCurve

Create a rational NURBS ellipse (degree 2, 9 control points).

Parameters:

  • ellipse (Ellipse) –

    The ellipse.

from_interpolation classmethod ¤
from_interpolation(points: list[Point], degree: int = 3) -> NurbsCurve

Create a NURBS curve that interpolates through given points.

Uses chord-length parameterization and scipy's make_interp_spline.

Parameters:

  • points (list[Point]) –

    Points to interpolate.

  • degree (int, default: 3 ) –

    Curve degree.

from_line classmethod ¤
from_line(line: Line) -> NurbsCurve

Create a degree-1 NURBS curve from a line.

Parameters:

  • line (Line) –

    The line.

from_parameters classmethod ¤
from_parameters(
    points: list[Point],
    weights: list[float],
    knots: list[float],
    mults: list[int] | None = None,
    degree: int = 3,
    multiplicities: list[int] | None = None,
) -> NurbsCurve

Create a NURBS curve from explicit parameters.

Parameters:

  • points (list[Point]) –

    Control points.

  • weights (list[float]) –

    Weights per control point.

  • knots (list[float]) –

    Unique knot values.

  • mults (list[int] | None, default: None ) –

    Multiplicities per knot.

  • degree (int, default: 3 ) –

    Curve degree.

from_points classmethod ¤
from_points(points: list[Point], degree: int = 3) -> NurbsCurve

Create a NURBS curve with given control points and clamped uniform knot vector.

Parameters:

  • points (list[Point]) –

    Control points.

  • degree (int, default: 3 ) –

    Curve degree.

length ¤
length() -> float

Approximate arc length by dense sampling.

point_at ¤
point_at(t: float) -> Point

Evaluate the curve at parameter t.

Parameters:

  • t (float) –

    Parameter value.

tangent_at ¤
tangent_at(t: float) -> Vector

Tangent vector at parameter t (unnormalized).

Uses finite differences on the rational curve.

Parameters:

  • t (float) –

    Parameter value.

to_linesegments ¤
to_linesegments(n: int = 100) -> list[Line]

Sample the curve into line segments.

Parameters:

  • n (int, default: 100 ) –

    Number of segments.

to_polyline ¤
to_polyline(n: int = 100) -> Polyline

Sample the curve into a polyline.

Parameters:

  • n (int, default: 100 ) –

    Number of segments.

transform ¤
transform(transformation: Transformation) -> None

Transform all control points in-place.

Parameters: