Curve From Control Points

../_images/example_curve_from_poles.png
# type: ignore

from compas.geometry import Point
from compas.geometry import Polyline
from compas.geometry import NurbsCurve
from compas_view2.app import App


points = [Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)]

curve = NurbsCurve.from_points(points)

# ==============================================================================
# Visualisation
# ==============================================================================

view = App()

view.add(curve.to_polyline(), linewidth=3)

view.add(
    Polyline(curve.points),
    show_points=True,
    pointsize=20,
    pointcolor=(1, 0, 0),
    linewidth=1,
    linecolor=(0.3, 0.3, 0.3),
)

view.run()
print(curve)
BSplineCurve
------------
Poles: [Point(0.000, 0.000, 0.000), Point(3.000, 6.000, 0.000), Point(6.000, -3.000, 3.000), Point(10.000, 0.000, 0.000)]
Knots: [0.0, 1.0]
Mults: [4, 4]
Degree: 3
Order: 4
Domain: (0.0, 1.0)
Closed: False
Periodic: False
Rational: False