Hi Nathan,

Note that the original code of curvature-test.cpp already has this instability, in case you are wondering if it is my own bug. 

I’m just wondering: how do you know it is a sign error? In fact, am not sure what’s happening under the hood when we say expression like

Kxy[1] = Linear(450) - K.segs[ix]*400;

where K.segs[ix] is an SBasis object. I looked around in the code and there didn’t seem to have operator-() defined between Linear and SBasis object (but the expression worked, and Linear object is not an SBasis object). So I don’t know where to look further to see if there is a degree increase going on anywhere.

Regards,
_______________________
Papoj "Hua" Thamjaroenporn
pt2277@...3110...





On Apr 28, 2014, at 2:22 AM, Nathan Hurst <njh@...1927...> wrote:

On Sun, Apr 27, 2014 at 09:03:32PM -0400, Papoj Thamjaroenporn wrote:

Hi,

I have noticed a few parts in lib2geom that give unstable output. I am trying to figure out what causes this and possible how to fix it:


In lib2geom?s toy example curvature-test.cpp, we fit osculating circle at a point of a given curve. We can slide along time parameter to fit osculating circle at different point on the curve. I modify the code a little to output the curvature plot of the curve in two ways:

1) Using D2<SBasis> to build curvature graph. Each segment in D2<SBasis> is a copy of SBasis from curvature curve K, offset by a constant. (as seen in RED).
Piecewise<SBasis> K = curvature(B);
2) Draw the graph directly by cairo_move_to(), cairo_line_to(). (as seen in GREEN).

The normal result would look like this:



However, when I hover my mouse around randomly (no input has been changed), the curve being fitted using D2<SBasis> will go wild randomly too:

Hi Papoj,
I wonder if there is a bug in the code which up degrees quads to
cubics, it looks like a sign error to me.

njh