Skip to content
/ Splines Public

Splines library with support for 1D to 4D splines

License

MovGP0/Splines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This library provides a set of classes to work with splines.

There are also helper types to aid with geometric calculations.

Credits

This library is based on the Mathfs library by Freya Holmer.

The main difference is that this library is more complete and has no dependency on Unity.

Dimensions

The types are available in 1D to 4D versions:

Dimension Description
1D Describe the movement of an object along a line (forward-backward movement)
2D Describe the movement of an object in a plane
3D Describe the movement of an object in space
4D Describe the movement of an object in space
Additional W-Axis that describe the twisting/rotation along a curve

Continuity

When splicing together multiple splines, it is important to consider the continuity of the splines.

This is important when considering visual artifacts, or especially when using splines for robotics control, where higher order continuity is required to ensure smooth motion.

The following table shows the continuity of some common spline types.

Spline Type Continuity Description
Linear Spline C0 continuous function
Bezier Spline C0 specific cases may be higher; ie., cubic Bezier can be C2
Quadratic Spline C1 continuous first derivative
Hermite Spline C1 continuous first derivative
Catmull-Rom Spline C1 continuous first derivative
Cardinal Spline C1 continuous first derivative
Cubic Spline C2 continuous second derivative
B-Spline varies depends on degree and knot vector, typically C2 for cubic B-splines
NURBS varies depends on degree and knot vector, typically C2 for cubic NURBS

Spline properties

Spline Type Properties
Linear Spline Piecewise linear functions
Continuous but not smooth
Does not capture curvature
Bezier Spline Defined by control points, typically cubic
Only the first and last control points are interpolated
Smooth and continuous
Local control by control points
Quadratic Spline Piecewise quadratic functions
Continuous first derivative
Captures basic curvature
Hermite Spline Defined using derivatives (tangents) at control points
Piecewise cubic
Continuous first derivative
Catmull-Rom Spline Special case of Hermite spline (tangents are automatically calculated)
Interpolates through control points
Smooth and continuous
Cardinal Spline Similar to Catmull-Rom but with adjustable tension parameter
Continuous and smooth
Interpolates through control points
Cubic Spline Piecewise cubic functions
Continuous first and second derivatives
Captures more complex curvature
B-Spline Piecewise polynomial functions
Generalization of cubic splines (can be of any degree)
Local control (change in one part of the spline affects only that part)
Smoothness can be controlled
Knot vector determines the spline
Captures complex curvature
NURBS Extension of B-splines with rational functions
Can represent both standard analytical shapes and freeform shapes
Allows for varying weights
Very flexible and powerful

Use cases

Spline Type Use Case
Linear Spline Simple and fast interpolation
Data visualization with simple trends
Connecting points in a straightforward manner
Bezier Spline Simple and intuitive curve design
Graphic design and vector graphics
Animation
User interface design
Quadratic Spline Slightly more accurate than linear for interpolation
Useful when the data trend is relatively simple
Graphics applications
Hermite Spline Smooth interpolation with control over tangents
Robotics and path planning
Keyframe animation
Catmull-Rom Spline Easy to use and intuitive for curve modeling
Computer graphics
Animation paths and camera movements
Cardinal Spline Flexible interpolation with tension control
Graphics and data visualization
Path and trajectory planning
Cubic Spline Smooth interpolation
Engineering and scientific applications
Data fitting where smoothness is required
Computer graphics
B-Spline Flexible and robust for modeling complex shapes
CAD/CAM applications
Image processing
Animation paths
NURBS High precision modeling
CAD, CAM, and CAE applications
Complex surfaces in computer graphics
Animation and rendering

Helper types

Folder Description
Geometric Algebra Bivector, Trivector, Multivector, etc. for geometric calculations
This types are used in vector algebra
Geometric Shapes Ray/Line/Line Segment, Polygons, Planes, circle, etc.
Used for geometric calculations and calculation of intersections
Numerics Specialized Vector and Matrix types
Interpolation Types for interpolating data points using splines
Outlier Handling Used to detect and remove outliers from a curve

About

Splines library with support for 1D to 4D splines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages