bugGNU Octave - Bugs: bug #45295, Division by Zero in 2nd derivative...

 
 

bug #45295: Division by Zero in 2nd derivative of NURBS surface

Submitter:  None
Submitted:  Wed 10 Jun 2015 12:50:42 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  cdf
Originator Name:  Sven Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  other
Operating System:  Any Fixed Release:  None
Planned Release:  None

Discussion locked!

Jump to the original submission

Fri 02 Oct 2015 04:07:29 PM UTC, comment #7: 

Rafa, is this issue fixed in the new release of NURBS?
Can I close the bug?
c.

Carlo de Falco <cdf>
Group Member
Mon 15 Jun 2015 01:36:27 PM UTC, comment #6: 

Hi,

thanks for your replies.

@Carlo: What I've done is the following; take the initial NURBS surface, insert knots until i have Bezier patches and then extract those patches. Bezier patches have C_inf continuity. This should also be true for the rational case.

@Rafa: I have had the same impression. I wasn't sure though. I was a bit irritated by the NaN and Inf entries and the issued warnings.

In order to resolve this issue, maybe outputting a warning would be the best way to go. What do you think?

Sven

Sven <sven>
Mon 15 Jun 2015 12:13:53 PM UTC, comment #5: 

Hi Sven,
although you get some invalid control points (Inf and Nan) in the structure for the second derivative, those invalid points should only affect the knot of the discontinuity. I have tried the examples and the computations in the interior of the elements using nrbdeval work correctly, both for curves and surfaces.

Regards,
Rafa

Anonymous
Mon 15 Jun 2015 11:43:25 AM UTC, comment #4: 

Hi,

nrbderiv is based on bspderiv that implements
the algorith A3.3 on page 98 of the book:

Piegl, Les and Tiller, Wayne
The Nurbs Book
Springer, New York, 1997 (2nd ed.)

which assumes the input knot vector has at most
p repetitions per knot, p being the degree,
corresponding to C0 continuity.

therefore you can compute the first derivative of a C0
curve but not its second derivative.

On the other hand, I believe that, if you take the C(-1) curve
obtained by performing the first derivative, 
the knots and control points of each knot span
should define a Bezier curve.

So if you have a BSpline curve you should be able to
compute the second derivative by cycling over each knotspan
and taking the local knotvector.

I am not sure how this works for rational BSplines,
maybe Rafael can comment on this.

c.

Carlo de Falco <cdf>
Group Member
Mon 15 Jun 2015 10:34:20 AM UTC, comment #3: 

Hi Carlo,

yes, my surface has only C0 continuity. Therefore the derivatives at the knots are undefined in general. However, if I am correctly informed, the derivatives are defined inside the knot spans as the function is a (piecewise) polynomial. So shouldn't it be possible to compute the derivative values inside the knot spans or would I have to separate the surface patch first?

Best regards,
Sven

Sven <sven>
Mon 15 Jun 2015 10:23:06 AM UTC, comment #2: 

Hi,

It seems that the example geometry you provided has only C0 regularity, so it is to be expected that the 2nd order derivatives be undefined.

using the knots and control points along the first direction
given in your example you can try the following univariate example:


>> knts = [1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9,9,9,9,9];
>> pts = [sin([0:48]/48*2*pi); cos([0:48]/48*2*pi)];
>> nrb = nrbmak (pts, knts);
>> u = linspace (1, 9, 1000);
>> [d1, d2] = nrbderiv (nrb);
>> [fu, fdu, fd2u] = nrbdeval (nrb, d1, d2, u);
>> plot (u, fdu(1,:))


notice the discontinuities in the first derivative are clearly visible in the plot,
we are considering whether it makes sense to add a check and an error message in cases like this.

Do you have an example where computing derivatives fails with a more regular geometry?

Carlo de Falco <cdf>
Group Member
Mon 15 Jun 2015 09:18:01 AM UTC, comment #1: 

This is probably related to computing the second derivatives in a surface that is not smooth enough, due to knot repetitions.

Can you try to reproduce the error in a simpler example? A surface of order 3 (degree 2) with one repeated internal knot should be enough. In the example, can you also include the points where you evaluate?

Anonymous
Wed 10 Jun 2015 12:50:42 PM UTC, original submission:  

When I try to calculate the 2nd derivatives (Hessian) of my NURBS surface, I get several divisions by Zero, that happen in bspderiv (the difference of the subtracted knots is zero). This results in several (+-) Inf and NaN entries in the Hessian.

I have attached my example data + the commands that lead to the error.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #34194:  nrb.m added by None (167KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by sven (Posted a comment)
  • -email is unavailable- added by cdf (Updated the item)
  • -email is unavailable- added by cdf
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-10-02 cdf Open/ClosedOpen Closed
        Discussion LockNone Locked
    2015-06-12 cdf Assigned toNone cdf
        Carbon-Copy- Added -email is unavailable-
    2015-06-10 None Attached File- Added nrb.m, #34194

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code