## Re: [PyX-devel] Curves with infinite curvature

 Re: [PyX-devel] Curves with infinite curvature From: Michael Schindler - 2005-09-09 10:39:28 Hello Jörg, On 09.09.05, Joerg Lehmann wrote: > On 09.09.05, Michael Schindler wrote: > > > This is what I have learned some years ago in a lecture on > > differential geometry: Consider a parameterization of a curve. The > > parameterization can be C-infty. But: if the length "velocity" (dx/dt, > > dy/dt) is zero somewhere, you can easily create a cusp in that curve. > > So, the curve is not smooth anymore, and in that cusp the tangent > > vector is not continuous: From both sides the tangents approach > > different values. > > Ah, ok, the limits from above and below do not agree. But in the output, > there is no cusp because we do not see the behaviour for param > 1. > Hmm... > > > In the present case we have only one side to do this. It would be very > > nice if already this worked. Nevertheless, the problem remains if the > > parameterization velocity vanishes somewhere in the middle. > > Can this happen in the case of Bézier curves? Very easily: n = normcurve_pt(0,0, 1,1, 0,1, 1,0) has a cusp at parameter 0.5, where the tangent switches from (0,1) to (0,-1). > > > So, maybe we're discussing a point which is quite academical anyway. > > > > I tapped into this while writing the parallel deformer where infinte > > curvatures are a big issue. > > I suspected something like this... It is even that bad that I consider giving up the "None" business for the curvature radius. But then, after thinking about it for a while, I consider it better to throw something like "None" rather than an "inf" or "-inf" value. For the latter it would be very convenient to calculate a curvature. One can divide by it and gets 0. On the other hand, when calculating with "inf" one soon gets "inf" everywhere, and the output will then be an invalid postscript. This would be really worse than thowing Exceptions here and there, when a "None" occurs where it should not. André asked me why there is a curveradius and not a curvature method. I answered that we need a length here, because lengths (and not inverse lengths) are natural to PyX. But I am not so convinced of this anymore because I need to convert the curvradius here and there in the deformers. Michael. -- "A mathematician is a device for turning coffee into theorems" Paul Erdös.

 [PyX-devel] Curves with infinite curvature From: Michael Schindler - 2005-09-09 08:07:04 Hello, I have hit a problem concerning the geometry things of the normpaths. Consider a Bezier curve that contains a point with infinite curvature. This is very easy to produce by setting e.g. the last two points to the same coordinates n = normcurve_pt(0,0, 1,1, 1,0, 1,0) The curveradius_pt returns "None" for parameter value 1. But the trafo/rotation does something quite unexpected. The tangent vector n.rotation([0.999999])[0].apply_pt(1, 0) seems to converge against (-1, 0) while adding more "9"s to the parameter. However, the tangent at the parameter value 1 is (1, 0). My question now is, how well do we want to really reproduce the true underlying geometry? We should return "None" for the rotation at such points also. Michael. -- "A mathematician is a device for turning coffee into theorems" Paul Erdös.
 Re: [PyX-devel] Curves with infinite curvature From: Joerg Lehmann - 2005-09-09 08:22:58 Hi Michael! On 09.09.05, Michael Schindler wrote: > I have hit a problem concerning the geometry things of the normpaths. > Consider a Bezier curve that contains a point with infinite curvature. > This is very easy to produce by setting e.g. the last two points to > the same coordinates > > n = normcurve_pt(0,0, 1,1, 1,0, 1,0) > > The curveradius_pt returns "None" for parameter value 1. But the > trafo/rotation does something quite unexpected. The tangent vector > > n.rotation([0.999999])[0].apply_pt(1, 0) > > seems to converge against (-1, 0) while adding more "9"s to the > parameter. However, the tangent at the parameter value 1 is (1, 0). > > My question now is, how well do we want to really reproduce the true > underlying geometry? We should return "None" for the rotation at such > points also. I think, we should return the correct rotation instead of None. Geometrically, everything is well-defined, it's only that we commit some numerical error because the length of (dx/dt, dy/dt) goes to zero. But we should be able to treat this case better. Jörg
 Re: [PyX-devel] Curves with infinite curvature From: Joerg Lehmann - 2005-09-09 09:16:46 Hi Michael, [ sorry, I forgot to CC the list before, here it goes again ] n 09.09.05, Michael Schindler wrote: > On 09.09.05, Joerg Lehmann wrote: > > On 09.09.05, Michael Schindler wrote: > > > On 09.09.05, Joerg Lehmann wrote: > > > > Hi Michael! > > > > > > > > On 09.09.05, Michael Schindler wrote: > > > > > I have hit a problem concerning the geometry things of the normpaths. > > > > > Consider a Bezier curve that contains a point with infinite curvature. > > > > > This is very easy to produce by setting e.g. the last two points to > > > > > the same coordinates > > > > > > > > > > n = normcurve_pt(0,0, 1,1, 1,0, 1,0) > > > > > > > > I think, we should return the correct rotation instead of None. > > > > > > That is my problem. If you have infinite curvature, there is no > > > geometrically defined rotation. Because the curvature is the change of > > > the normal vector along the curve length, projected onto the tangent > > > vector (or equally the other way round), you see that both vectors > > > change infinitely fast. Thus, they do not exist in this point. > > > > Maybe I'm missing the point, but for me the rotation doesn't have > > anything to do with the curvature, but is solely defined in terms of > > the tangent. > > Correct. The tangent is not defined in such point. Ok, this sounds reasonable. > This is what I have learned some years ago in a lecture on > differential geometry: Consider a parameterization of a curve. The > parameterization can be C-infty. But: if the length "velocity" (dx/dt, > dy/dt) is zero somewhere, you can easily create a cusp in that curve. > So, the curve is not smooth anymore, and in that cusp the tangent > vector is not continuous: From both sides the tangents approach > different values. Ah, ok, the limits from above and below do not agree. But in the output, there is no cusp because we do not see the behaviour for param > 1. Hmm... > > So I would assume that we take the limiting case of the rotation defined > > by the tangent as param->1. This you can easily calculate via l'Hopital > > and it gives you (-1, 0) in the present case. > > In the present case we have only one side to do this. It would be very > nice if already this worked. Nevertheless, the problem remains if the > parameterization velocity vanishes somewhere in the middle. Can this happen in the case of Bézier curves? > > Having said all that, I just want to remark that Ghostscript also > > isn't quite a fan of a Bézier curve with two identical control points. > > Just try to stroke the above normpath and view the resulting EPS > > file... > > Well, my ghostscript does not complain. But the tangent does not seem > to be (-1, 0) at the end. Ah, sorry, of course it works, there was another problem. And yes, the tangent does not looks like being (-1, 0) at then end, although this is the limit from below. I'm really getting confused now. > > So, maybe we're discussing a point which is quite academical anyway. > > I tapped into this while writing the parallel deformer where infinte > curvatures are a big issue. I suspected something like this... Jörg
 Re: [PyX-devel] Curves with infinite curvature From: Michael Schindler - 2005-09-09 10:39:28 Hello Jörg, On 09.09.05, Joerg Lehmann wrote: > On 09.09.05, Michael Schindler wrote: > > > This is what I have learned some years ago in a lecture on > > differential geometry: Consider a parameterization of a curve. The > > parameterization can be C-infty. But: if the length "velocity" (dx/dt, > > dy/dt) is zero somewhere, you can easily create a cusp in that curve. > > So, the curve is not smooth anymore, and in that cusp the tangent > > vector is not continuous: From both sides the tangents approach > > different values. > > Ah, ok, the limits from above and below do not agree. But in the output, > there is no cusp because we do not see the behaviour for param > 1. > Hmm... > > > In the present case we have only one side to do this. It would be very > > nice if already this worked. Nevertheless, the problem remains if the > > parameterization velocity vanishes somewhere in the middle. > > Can this happen in the case of Bézier curves? Very easily: n = normcurve_pt(0,0, 1,1, 0,1, 1,0) has a cusp at parameter 0.5, where the tangent switches from (0,1) to (0,-1). > > > So, maybe we're discussing a point which is quite academical anyway. > > > > I tapped into this while writing the parallel deformer where infinte > > curvatures are a big issue. > > I suspected something like this... It is even that bad that I consider giving up the "None" business for the curvature radius. But then, after thinking about it for a while, I consider it better to throw something like "None" rather than an "inf" or "-inf" value. For the latter it would be very convenient to calculate a curvature. One can divide by it and gets 0. On the other hand, when calculating with "inf" one soon gets "inf" everywhere, and the output will then be an invalid postscript. This would be really worse than thowing Exceptions here and there, when a "None" occurs where it should not. André asked me why there is a curveradius and not a curvature method. I answered that we need a length here, because lengths (and not inverse lengths) are natural to PyX. But I am not so convinced of this anymore because I need to convert the curvradius here and there in the deformers. Michael. -- "A mathematician is a device for turning coffee into theorems" Paul Erdös.