From a27e9c0bb0ce35791044c496e587d21758b245c1 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 10 Apr 2014 05:30:06 +0000 Subject: [PATCH] InterpolateBezier leads to List_Read with negative index (see demos/splines.geo) --- Geo/GeoInterpolation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp index 1270eb7c46..0e81a9a6ef 100644 --- a/Geo/GeoInterpolation.cpp +++ b/Geo/GeoInterpolation.cpp @@ -135,12 +135,14 @@ SPoint2 InterpolateCubicSpline(Vertex *v[4], double t, double mat[4][4], } return p; } + // Bezier static Vertex InterpolateBezier(Curve *Curve, double u, int derivee) { int NbCurves = (List_Nbr(Curve->Control_Points) - 1) / 3; int iCurve = (int)floor(u * (double)NbCurves); - if(iCurve == NbCurves) iCurve -= 1; // u = 1 + if(iCurve >= NbCurves) iCurve = NbCurves - 1; // u = 1 + if(iCurve <= 0) iCurve = 0; double t1 = (double)(iCurve) / (double)(NbCurves); double t2 = (double)(iCurve+1) / (double)(NbCurves); double t = (u - t1) / (t2 - t1); -- GitLab