[opengtl-commits] [314] fix interpolateCubic1D to be really cubic even with few points in the curve |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 314
Author: cyrille
Date: 2008-08-05 08:36:57 +0200 (Tue, 05 Aug 2008)
Log Message:
-----------
fix interpolateCubic1D to be really cubic even with few points in the curve
Modified Paths:
--------------
trunk/OpenGTL/OpenCTL/OpenCTL/ctlstdlib.ctl
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/ctlstdlib.ctl
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/ctlstdlib.ctl 2008-08-04 08:21:27 UTC (rev 313)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/ctlstdlib.ctl 2008-08-05 06:36:57 UTC (rev 314)
@@ -149,26 +149,26 @@
{
if( table[i][0] <= p && p < table[i+1][0] )
{
- if( i < 1 || i >= table.size-2 )
+/* if( i < 1 || i >= table.size-2 )
{
return interpolate1D( table, p );
- }
+ }*/
float s = (p - table[i][0]) / (table[i+1][0] - table[i][0]);
- float dx0 = (table[i][0] - table[i-1][0]);
float dx1 = (table[i+1][0] - table[i][0]);
- float dx2 = (table[i+2][0] - table[i+1][0]);
- float dy0 = (table[i][1] - table[i-1][1]);
float dy1 = (table[i+1][1] - table[i][1]);
- float dy2 = (table[i+2][1] - table[i+1][1]);
float m0;
float m1;
if( i > 0 )
{
+ float dy0 = (table[i][1] - table[i-1][1]);
+ float dx0 = (table[i][0] - table[i-1][0]);
m0 = (dy1 + dx1 * dy0 / dx0) / 2;
}
if( i < table.size-2 )
{
+ float dx2 = (table[i+2][0] - table[i+1][0]);
+ float dy2 = (table[i+2][1] - table[i+1][1]);
m1 = (dy1 + dx1 * dy2 / dx2) / 2;
}
if( i == 0) {