![]() |
TinySpline
Spline Library for a Multitude of Programming Languages
v0.3.0
|
TinySpline is a small, yet powerful library for interpolating, transforming, and querying arbitrary NURBS, B-Splines, and Bézier curves. The library is implemented in ANSI C (C89) and provides a wrapper for C++ along with auto-generated bindings for C#, D, Go, Java, Lua, Octave, PHP, Python, R, and Ruby.
MIT License - see the LICENSE file in the source distribution.
The following listing uses the ANSI C interface:
The same example using the C++ interface:
Snapshot releases are available at releases.
TinySpline uses the CMake build system to compile and package its interfaces. The following compiler suites are tested: GCC, Clang, and MSVC. In order to create the bindings, Swig (3.0.1 or later) must be available. Each binding may have further dependencies to generate the source code of the target language. The following table gives an overview:
Language | Dependencies to Generate Source | (Relative) Output Directory |
---|---|---|
C# | csharp | |
D | - | dlang |
Golang | - | go |
Java | Java Development Kit | org/tinyspline |
Lua | Lua headers | lua |
Octave | Octave headers | octave |
PHP | PHP (Zend) headers * | php |
Python | Python headers | python |
R | R headers and RCPP | r |
Ruby | Ruby headers | ruby |
The following tools are required if you want to compile and package the the source code files of the corresponding binding:
Language | Required Tool(s) | Output File |
---|---|---|
C# | Any of: csc, mcs, dmcs, gmcs | TinySpline.dll |
Java | javac and jar (available in JDK) | tinyspline.jar |
Checkout the repository and cd into it:
Afterwards, create a build directory and cd into it:
Finally, run CMake and build the project:
If you want to build a specific binding, use -DTINYSPLINE_ENABLE_<LANGUAGE>
when setting up cmake (<LANGUAGE>
is interface you want to build) . For example:
To enable all interfaces, use -DTINYSPLINE_ENABLE_ALL_INTERFACES
:
You will find the resultant libraries and packages in tinyspline/build/lib
.
While generating the Python binding, Swig needs to distinguish between Python 2 and Python 3. That is, Swig uses the command line parameter -py
to generate Python 2 compatible code and -py3
to generate Python 3 compatible code. Accordingly, Swig is configured depending on the Python version found by CMake during initialization. On systems with multiple versions of Python installed, CMake usually chooses the more recent one. If you want to use a specific version of Python instead, set the environment variable 'TINYSPLINE_PYTHON_VERSION' to '2' or '3'.TINYSPLINE_VERSION
The following example shows how to force CMake to use Python 2 rather than Python 3:
The following command installs TinySpline to your system:
This command also installs a set of CMake config scripts and pkg-config files (for the C and C++ interface respectively). The CMake config script of the C interface exports the following variables:
add_definitions
.The CMake config script of the C++ interface exports the same variables except that they have prefix TINYSPLINECXX
, e.g. TINYSPLINECXX_INCLUDE_DIRS
.
Use the CMake commands find_package(tinyspline)
(C) and find_package(tinysplinecxx)
(C++) to include TinySpline into your project.
Depending on your configuration, binding-related distribution files are generated within the root of your build directory. For example, the file setup.py
is generated if Python is enabled. Currently, the following build tools are supported: Setuptools (Python), Maven (Java), and Luarocks (Lua).
[1] is a very good starting point for B-Splines.
[2] explains De Boor's Algorithm and gives some pseudo code.
[3] provides a good overview of NURBS with some mathematical background.
[4] is useful if you want to use NURBS in TinySpline.