Skip to content

3.9.0

Compare
Choose a tag to compare
@ianmackenzie ianmackenzie released this 12 Nov 01:30

NURBS curves

This release extends the work on spline functionality from the last release and adds support for rational quadratic and cubic splines in the RationalQuadraticSpline2d, RationalQuadraticSpline3d, RationalCubicSpline2d and RationalCubicSpline3d modules. This means it is now possible to create quadratic or cubic NURBS curves in 2D or 3D using elm-geometry! For example, to create a NURBS curve representing a perfect circle (consisting of four rational quadratic spline segments), you could write

splineSegments =
    RationalQuadraticSpline2d.bSplineSegments
        [ 0, 0, 1, 1, 2, 2, 3, 3, 4, 4 ]
        [ ( Point2d.pixels 300 0, 1 )
        , ( Point2d.pixels 300 300, 1 / sqrt 2 )
        , ( Point2d.pixels 0 300, 1 )
        , ( Point2d.pixels -300 300, 1 / sqrt 2 )
        , ( Point2d.pixels -300 0, 1 )
        , ( Point2d.pixels -300 -300, 1 / sqrt 2 )
        , ( Point2d.pixels 0 -300, 1 )
        , ( Point2d.pixels 300 -300, 1 / sqrt 2 )
        , ( Point2d.pixels 300 0, 1 )
        ]

See Wikipedia for some explanation, but note that:

  • Only the ratios between knot values matter, so the 0..4 knot sequence here is equivalent to the 0..2π knot sequence on Wikipedia.
  • elm-geometry uses a different knot convention that avoids the 'dummy' first and last knots, so note that the first and last knots are only repeated twice here instead of three times.

Ellipsoids

This release also adds an Ellipsoid3d type and module for representing ellipsoids. Thanks to @g-belmonte for contributing this in #135! (Eventually elm-3d-scene will get support for rendering ellipsoids.)