All Projects → pradeep-pyro → Tinynurbs

pradeep-pyro / Tinynurbs

Licence: bsd-3-clause
C++ library for NURBS curves and surfaces

Labels

Projects that are alternatives of or similar to Tinynurbs

re-gent
A Distributed Clojure agent for running remote functions
Stars: ✭ 18 (-86.05%)
Mutual labels:  curve
Hslcontrolsdemo
HslControls控件库的使用demo,HslControls是一个工业物联网的控件库,基于C#开发,配套HslCommunication组件可以实现工业上位机软件的快速开发,支持常用的工业图形化控件,快速的集成界面开发。 主要包含了按钮,开关,进度条,信号灯,数码管,时钟,曲线显示控件,仪表盘控件,管道控件,瓶子控件,饼图控件,传送带控件,温度计控件,鼓风机控件,阀门控件,电池控件等等。
Stars: ✭ 389 (+201.55%)
Mutual labels:  curve
Curve Fit
Curve-Fit is an Android library for drawing curves on Google Maps
Stars: ✭ 63 (-51.16%)
Mutual labels:  curve
react-svg-curve
React components to draw different types of curves with svg
Stars: ✭ 42 (-67.44%)
Mutual labels:  curve
Nurbs Python
Object-oriented pure Python B-Spline and NURBS library
Stars: ✭ 295 (+128.68%)
Mutual labels:  curve
Verb
Open-source, cross-platform NURBS
Stars: ✭ 601 (+365.89%)
Mutual labels:  curve
similarity measures
Quantify the difference between two arbitrary curves in space
Stars: ✭ 140 (+8.53%)
Mutual labels:  curve
Wotan
Automagically remove trends from time-series data
Stars: ✭ 86 (-33.33%)
Mutual labels:  curve
Flutter page transition
This is Flutter Page Transition Package
Stars: ✭ 314 (+143.41%)
Mutual labels:  curve
Joeecc
Elliptic Curve Cryptography playground/toolkit written in pure Python
Stars: ✭ 46 (-64.34%)
Mutual labels:  curve
D2PCurvedModal
An elegant and curved modal View for iOS (Swift)
Stars: ✭ 59 (-54.26%)
Mutual labels:  curve
Glmaps
Data visualization examples and tutorials from scratch. 数据可视化示例代码集与新手学习教程。
Stars: ✭ 288 (+123.26%)
Mutual labels:  curve
Moto.js
A light motion library with curvilinear support.
Stars: ✭ 24 (-81.4%)
Mutual labels:  curve
Flutter-Anim
Fluent Flutter Animation library. Describe Sequences & Parallel animation's workflow, setup startDelay, duration and curve, then run !
Stars: ✭ 35 (-72.87%)
Mutual labels:  curve
Noble Bls12 381
Fastest implementation of BLS12-381 in a scripting language. High-security, auditable, 0-dependency aggregated signatures / zk-snarks over pairing-friendly curve
Stars: ✭ 73 (-43.41%)
Mutual labels:  curve
Pathslider
Numerical slider that follows a Bezier path
Stars: ✭ 15 (-88.37%)
Mutual labels:  curve
Defi Sdk
DeFi SDK Makes Money Lego Work
Stars: ✭ 440 (+241.09%)
Mutual labels:  curve
Crescento
Add curve at bottom of image views and relative layouts.
Stars: ✭ 1,289 (+899.22%)
Mutual labels:  curve
Curvejs
Made curve a dancer in HTML5 canvas - 魔幻线条
Stars: ✭ 1,251 (+869.77%)
Mutual labels:  curve
Beziercurve
Bezier curve master
Stars: ✭ 43 (-66.67%)
Mutual labels:  curve

tinynurbs

Build Status

This is a lightweight header-only C++14 library for Non-Uniform Rational B-Spline curves and surfaces. The API is simple to use and the code is readable while being efficient.

Some of the main features include:

  • Supports non-rational and rational curves and surfaces of any order
  • Evaluate point and derivatives of any order
  • Knot insertion, splitting without affecting the original shape
  • Wavefront OBJ format I/O

The library is under development.

Dependencies

  • glm (version 0.9.9 where PR #584 is merged is required since tinynurbs uses the glm::vec<dim, T> type)
  • C++14 compliant compiler

Usage

The entire API consists of free functions named curve* and surface* which accept a Curve / RationalCurve and Surface / RationalSurface object, respectively. Some example usage is given below.

Create a non-rational planar curve:

tinynurbs::Curve<float> crv; // Planar curve using float32
crv.control_points = {glm::vec3(-1, 0, 0), // std::vector of 3D points
                      glm::vec3(0, 1, 0),
                      glm::vec3(1, 0, 0)
                     };
crv.knots = {0, 0, 0, 1, 1, 1}; // std::vector of floats
crv.degree = 2;

Check if created curve is valid:

if (!tinynurbs::curveIsValid(crv)) {
    // check if degree, knots and control points are configured as per
    // #knots == #control points + degree + 1
}

Evaluate point and tangent on curve:

glm::vec3 pt = tinynurbs::curvePoint(crv, 0.f);
// Outputs a point [-1, 0]
glm::vec3 tgt = tinynurbs::curveTangent(crv, 0.5f);
// Outputs a vector [1, 0]

Insert a single knot at u=0.25 and double knot at u=0.75:

crv = tinynurbs::curveKnotInsert(crv, 0.25);
crv = tinynurbs::curveKnotInsert(crv, 0.75, 2);

Left: original curve, Right: after knot insertion

curve knotinsert

Write the curve to an OBJ file:

tinynurbs::curveSaveOBJ("output_curve.obj", crv);

creates a file with the following contents:

v -1 0 0 1
v -0.75 0.5 0 1
v 0 1.25 0 1
v 0.5 0.75 0 1
v 0.75 0.5 0 1
v 1 0 0 1
cstype bspline
deg 2
curv 0 1 1 2 3 4 5 6
parm u 0 0 0 0.25 0.75 0.75 1 1 1
end

Create a rational surface shaped like a hemisphere:

tinynurbs::RationalSurface<float> srf;
srf.degree_u = 3;
srf.degree_v = 3;
srf.knots_u = {0, 0, 0, 0, 1, 1, 1, 1};
srf.knots_v = {0, 0, 0, 0, 1, 1, 1, 1};

// 2D array of control points using tinynurbs::array2<T> container
// Example from geometrictools.com/Documentation/NURBSCircleSphere.pdf
srf.control_points = {4, 4, 
                      {glm::vec3(0, 0, 1), glm::vec3(0, 0, 1), glm::vec3(0, 0, 1), glm::vec3(0, 0, 1),
                       glm::vec3(2, 0, 1), glm::vec3(2, 4, 1),  glm::vec3(-2, 4, 1),  glm::vec3(-2, 0, 1),
                       glm::vec3(2, 0, -1), glm::vec3(2, 4, -1), glm::vec3(-2, 4, -1), glm::vec3(-2, 0, -1),
                       glm::vec3(0, 0, -1), glm::vec3(0, 0, -1), glm::vec3(0, 0, -1), glm::vec3(0, 0, -1)
                      }
                     };
srf.weights = {4, 4,
               {1,       1.f/3.f, 1.f/3.f, 1,
               1.f/3.f, 1.f/9.f, 1.f/9.f, 1.f/3.f,
               1.f/3.f, 1.f/9.f, 1.f/9.f, 1.f/3.f,
               1,       1.f/3.f, 1.f/3.f, 1
               }
              };

Split the surface into two along v=0.25:

tinynurbs::RationalSurface<float> left, right;
std::tie(left, right) = tinynurbs::surfaceSplitV(srf, 0.25);

Left: original surface, Right: after splitting

split surface

Write the surface to an OBJ file:

tinynurbs::surfaceSaveOBJ("output_surface.obj", srf);

creates a file with the following contents:

v 0 0 1 1
v 2 0 1 0.333333
v 2 0 -1 0.333333
v 0 0 -1 1
v 0 0 1 0.333333
v 2 4 1 0.111111
v 2 4 -1 0.111111
v 0 0 -1 0.333333
v 0 0 1 0.333333
v -2 4 1 0.111111
v -2 4 -1 0.111111
v 0 0 -1 0.333333
v 0 0 1 1
v -2 0 1 0.333333
v -2 0 -1 0.333333
v 0 0 -1 1
cstype rat bspline
deg 3 3
surf 0 1 0 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
parm u 0 0 0 0 1 1 1 1
parm v 0 0 0 0 1 1 1 1
end

Primary Reference

  • "The NURBS Book," Les Piegl and Wayne Tiller, Springer-Verlag, 1995.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].