# Exact curve modeling with nurbs - quadrant, helix. problem with curvature and torsion values

Hi all,
i try to validate my octave script, which calculates curvature and torsion of an arbitrary spatial NURBS-curve at given u parametric point (which is part of the knot-span). I tried to do that using rhino and grasshopper combined. I am sure, my code calculates curvature correctly (tested on quarter of circle [quadrant] and get always the analytical expected value). In my code i implemented the necessary algorithms from “the nurbs book”.

PART1:
when i use the exact same control points, both in my code and in rhino/gh [R/GH], with all weight equal to 1 (so not a perfect quadrant, and bsplines not nurbs), i get different curvature values, using my code and R/GH, when i evaluate them in the same parametric point. Same occurs, with spatial curves, and this is very confusing.

PART2:
at the end, everything can be boiled down to a single question:
what is the way of evaluating NURBS basis functions (and its 1,2,3,4,… derivatives) at given parametric point?

However, I also recognized, that the “spiral” command does not generate a cylindrical helix with constant curvature and torsion values, which I am also very confused about.

QUESTIONS:

• What can be the reason of having different curvature values in planar case (PART1)?
• How can one generate a spatial curve with constant curvature and torsion values?
• What is the way of evaluating NURBS basis functions (and its 1,2,3,4,… derivatives) at given parametric point?

Thanks for your time trying to help me!

i get different curvature values, using my code and R/GH

Then your code has an error. Rhino has been used by 100K’s of users over 25+ years I bet the error is in your code not ours. Are the knots the same as well? Also beware of the knot indexing convention in “The NURBS Book” differs from OpenNurbs, look at the comments in opennurbs_evaluate_nurbs.h for the function ON_EvaluateNurbsBasis(…).

everything can be boiled down to a single question:
what is the way of evaluating NURBS basis functions

Nothing boils down to this. How Rhino evaluates NURBS curves is an implementation detail. However, If you want to know OpenNurbs is open source and you can inspect the code yourself.

the “spiral” command does not generate a cylindrical helix

You are correct. If you make a helix with the Spiral command the resulting curve is an approximation not a perfect nurbs helix. The spiral command can make many kinds of “spirals” most of which have no perfect NURBS representations. So the Spiral command does not special case the helix.

How can one generate a spatial curve with constant curvature and torsion values?

Is that helix? I’m not sure if a helix has an exact nurbs representation. The problem is that a nurbs circle doesn’t not have a constant speed parameterization. Good math problem.

As a general comment finding and fixing your evaluation bug is the debugging process. Testing cases like circles where you know, or can easily compute the answer using calculus is a good approach. Also try other simple cases lines, parabolas, cubic beziers.

Then your code has an error. Rhino has been used by 100K’s of users over 25+ years I bet the error is in your code not ours.

I did not say your code is incorrect. I try/tried to find the reason for the different results. Reasoning with the number of users and years does not move finding the solution forward, either. However, as you came up with those numbers and statement, I probably will have to notify the maintainers of the python geomdl library, and the editors of the mechanical journals where the results were published, coinciding/converging towards the analytical/expected solution, because, following idea of your statement, the library is buggy and the published results are incorrect, as they coincide with my result, and I was not able to reproduce withR/GH. (the number of users and years people using those libraries, I let for people to google, who are interested in it. I am not.). Also, it has probably a really low chance, that a code which obtains the analytical result for curvature for planar curves, is buggy (again, i do not imply that your code is buggy, i wrote to the forum to find out the reason why i can not reproduce certain stuff with GH). Do we really have to walk down this path? I do not think it would lead anywhere just rage, and looks also not professional.

Nothing boils down to this.
I am not sure what you meant, I was wondering if there is a way to retrieve with GH the evaluated base functions in a given point. So, at the end by solving my problem, it does/did.

How Rhino evaluates NURBS curves is an implementation detail. However, If you want to know OpenNurbs is open source and you can inspect the code yourself.
Yes it is an implementation detail but i was not interested about the source code either. I do not really think there are any naive people living on Earth who believes a commercial company would give out the source code on a forum. Also, the nurbs book provides code snippets, as we know.

Is that helix?
Yes, it is. In case you do not believe me (why would you), you can easily derive / find on internet.

I wrote to the company first an email, and in their response i was suggested as a new R/GH user to ask question on forum, as people are helpful here. However, intention of help was the last thing i found in this answer, which is kind of disappointing. As I proved myself, using free python nurbs libraries, that my functions obtain correct results for both planar and spatial cases with random control point coordinates and weights (octave and short python script can be provided), from my side continuing discussing anything related to the previously sketched problem, lost its meaning, no one needs to react this message (or if one will react, I will not.)

I am sorry for receiving and having to write email in such tone. I saw on linkedIn, you have phd in mathematics and more than 2 decades of software developing experiences. I would have loved to discuss problems in merits, and not stuck on the “your code is wrong” level.

Have a great day!