NURBS : Important and basic points

Hey Guys! Welcome to Nurbs calculator. Unfortunately, my app is not working at the moment. I’m implementing NURBS surfaces as well. Stay tuned and thanks for the patience. Please send me an email on pawangami@yahoo.com, if you have any suggestions or feedback.


NURBS web-app using three.js

Curve parameters

A NURBS curve can be created by just 3 parameters – degree, control point and knot vector.

  • Knot vector: It is a sequence of some real numbers, in non-decreasing order. This sequence depends on the assumption of u values. If you are assuming that u varies from 0 to 1, then knot vector is the sequence of numbers, between 0 and 1. So basically knot values are u values. There is no significance of each knot value separately. It is the sequence, which is important. The total number of knots = number of control points + degree + 1. If the degree of the curve is 2 and there are 4 control points, then there will be total 7-knot values. A curve will be called as Non-Uniform, if the sequence of these knot values is non-uniform (e.g 0.0, 0.4, 0.5, 0.6, 0.9, 0.95, 1.0 ) and called as uniform if this sequence is uniform (e.g. 0.0, 0.167, 0.333, 0.5, 0667, 0.833, 1.0).
  • Degree and order: It is the measure of the curvature of the curve. Order of the curve = degree + 1.
  • Control points: The control points determine the shape of the curve. Each point is having 4 float values – x position, y position, z position and weight of the control point. The minimum number of control points required to render a NURBS curve is the same as the order of the curve. So you need at least 4 control points for degree 3 curve.
  • U parameter: In mathematics, the equation of a curve can be expressed as a function of an independent variable, called as a parameter. In nurbs-calculator, we call this parameter as u parameter. U parameter is used to calculate the coordinates of a point, on the curve, from its parametric equation. Generally, it is assumed that u is 0 at the start of the curve and 1 at the end. So at the middle of the curve, the value of u will be 0.5. Let’s assume that there is a line starting at (1,1) and ending at (2,2). Also, assume that u=0 at start and u=1 at the end. If you are asked to find the coordinates of the point, which lies at the middle of the line, then in the mathematical term you will say that what should be coordinates of the point at u=0.5. You can provide this u value to the parametric equation of the line and calculate the coordinates at the middle point. You can also assume that u=1 at start and u=2 at the end or u=10 at start and u=100 at the end. It is your assumptions which defines the middle point of the curve, so for 0< u < 1, middle point is at u = 0.5, for 1 < u < 2, middle is at u = 1.5 and for 10 < u < 100 middle is at u=55.
  • Knot multiplicity: Multiplicity means repetition of knot values. Multiplicity is a property of knots that refers to the number of control points associated to a knot. On a cubic curve (degree 3), a knot can have a multiplicity of 1, 2, or 3, but not more than 3. Similarly for degree 2 curve, the multiplicity can’t be more than 2. If knot values have multiplicity = degree + 1 at the start, then the curve will be clamped at the start, that means the curve touches the first control point. If the multiplicity < (degree+ 1) at the start, then the curve will not touch the first control point and the curve will start at u = k[p], where p=degree. Same is applicable for the end knots. If the multiplicity at the end is < (degree + 1), then the curve will not touch the last control point and curve will end at u=k[m-p], where m = (total number of knots – 1). That means, if knot vector is = {0, 0.111, 0.222, 0.333, 0.445, 0.556, 0.667, 0.778, 0.889, 1.0} for degree 2 curve, then the curve will start from u = 0.2, which is k[2] and end at u=0.778, which is k[7]. If the multiplicity > (degree + 1), then the curve will split into disjoint parts and the control point will be unused.

Bézier curves, B-Splines and NURBS

  • Bézier curves: The number of control points in Bézier curves is exactly equal to (degree + 1). That means for degree 2 curve, there will be 3 control points. If we add 1 control point, then the degree will also increase by 1. This is the main limitation of Bezier curves. Sometimes we want to add more control point at some portion of the curve (to precisely control the shape of that portion), but if the degree is increased, then it will affect the shape of the entire curve.
    • Since the number of control points and degree are fixed, so according to the formula –> k = n+p+1, the number of knots will always be 2*(degree+1).
    • It is always clamped at start and end. That means the curve is tangent at the first and last control point.
    • Since it is clamped at start and end, so first degree+1 knot values will be 0 and last degree+1 knot values will be 1. That means the knot vector of Bezier curve doesn’t contain any value other than 0 and 1.
    • It may be a rational curve, means all the control points can have different weights.
  • B-Splines:
    • Minimum number of control points = degree + 1. More control points can be added without increasing the degree
    • Knots values can be uniform or non-uniform.
    • The curve may or may not be clamped at endpoints. That means the curve may or may not touch the endpoints.
    • It is always irrational, so all the control points should have equal weights, usually 1.
  • NURBS:
    • All the properties are same as b-splines, except that it considers the weight of the control points. So each control point can have different weight. That is why it is called as rational b-splines.

 

 

Advertisements

nurbsdemo_JanForetnik — mugehalici

http://geometrie.foretnik.net/files/NURBS-en.swf

via nurbsdemo_JanForetnik — mugehalici

Nurbs calculator tutorial – 1

For introduction of nurbs calculator, please read previous post.

 

In this and further tutorials I’ll create some linear, quadratic and cubic curves, using nurbs calculator. You can create a nurbs curve of any degree, but generally, curves of degree 2 and 3 are used, because higher degree curves requires more control points and so it becomes difficult to control the shape of the curve. A nurbs curve needs at least degree+1 control points. So if the degree of the curve is 100, then it requires minimum 101 control points and 202 knot values, to render the curve and it is very difficult to correctly position so many control points. A curve having degree 1 is called as linear (that means it is a line), having degree 2 is called as quadratic and having degree 3 is called as cubic

Find out the coordinates of mid point of a line: 

This is a very generic and simple problem and you don’t have to be an engineer to solve this 🙂 . Let’s assume that there is line in XY plane and the coordinates of the start points are (5.3, 6.4) and end point are (2.5, 4.3). Since it is in XY plane, so z coordinate will be 0. How can we find out the coordinates of the middle point of this line ? If you know the parametric equation of line, then it could be easy for you, but with the help of nurbs calculator you can do this in just few steps, even if you don’t know about parametric equation.

  • Go to the website http://nurbscalculator.in
  • Enter degree = 1
  • Remove all control points (except two points, which are required to draw a line) and enter the values of x and y coordinates of start and end points. Keep the value of z=0 and w=1.
  • Make sure that ‘clamped at start’ and ‘clamped at end’ are checked.
  • Enter the value of u parameter as 0.5, because we want to evaluate the mid point.
  • The coordinates of the point will shown in front of ‘Evaluated  point’ and the point will be displayed in yellow colour in the webGL window.

See the below image for illustration.

linear

You can evaluate the point on the line for any u value between 0 and 1, by moving the slider.

What is the parametric equation of line?

If the coordinates of start point of a line are (x1, y1) and end point are (x2, y2), then the parametric equation of line is given by –

x = (1-t)*x1 + t*x2

y = (1-t)*y1 + t*y2

which can be written in simplified form as –

x = x1 + (x2 – x1) * t

y = y1 + (y2 – y1) * t

where t is a parameter whose value is 0 at start point and 1 at end point.

Please share this post with your friends and colleagues, so that it can reach to the person who is new to geometric modelling and computer graphics.

Follow nurbscalculator on WordPress.com

WebGL based NURBS Demo

Hey Guys! Welcome to Nurbs calculator. Unfortunately, my app is not working at the moment. I’m implementing NURBS surfaces as well. Stay tuned and thanks for the patience. Please send me an email on pawangami@yahoo.com, if you have any suggestions or feedback.

 

Nurbs_demo_1
NURBS Software using Three.js

You might have seen many demos of NURBS (Non Uniform Rational B-Spline), which are either flash based or java applet based, but none of these provide you full control on all the parameters of NURBS curves. Nurbs-calculator is the world’s first browser based application, which combines the power of three.js and angular.js to give the best user experience.  Three.js is one of the best javascript api to create webGL applications and angular.js is a perfect web application framework to create dynamic and extensible web apps.

NURBS is one of core fundamentals of most of the CAD software like Autodesk Maya , Rhinoceros 3D, SolidWorks etc  and generally it is considered as highly complicated mathematical concept. If you are new to NURBS, then ‘NURB curves – a guide for the uninitiated‘ will give you a good start. To understand the mathematics of NURBS and NURBS properties, visit – http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/.

But these websites are not helpful to understand the NURBS properties, until you have a software application where you can create some sample curves and see the effect of changing the curve parameter. This is where you need nurbs-calculator. This is a browser based app and doesn’t require any kind of installation on desktop PC. Just go to the URL – nurbscalculator.in and start creating curves. Once the curve is created, you can evaluate the point on the curve. Evaluation means finding the coordinates of a point on the curve corresponding to a parameter.

If you just want to create some splines and free form curves and not interested in understanding NURBS, then also nurbs-calculator is very helpful. It is very easy to use and can be accessed from mobile / tablet / laptop browsers. You can add / modify / remove control points in the webGL window on the right side and can set the precise values by using the edit boxes on the left side. More details about this can be found in the ‘How to use‘ section of the website.

I’ll put some tutorials in my next post, to demonstrate how one can use nurbs-calculator to create linear, quadratic or cubic splines.