BLT: bug? in spline: spline natural/quadratic 
Author Message
 BLT: bug? in spline: spline natural/quadratic

Hi,

The spline function used on a destination vector of length 1
sets "funny" values for spline quadratic vsrc(>3) vdest(1)

I use the "spline" to do a table lookup for linearisation of a sensor
transfer function.
the reference vector has allways 3 or more elements and i use a vector
of length:1 to interpolate my input value to an output value.

Script for testing
bltvector.tcl {
        package require BLT
        namespace import blt::*

        vector create xa(1) ; set xa(0) 1.55
        vector create ya(1) ; set ya(0) 1.6
        vector create za(1) ; set za(0) 1.6
        vector create xb(3) ; set xb(0) 1.4 ; set xb(1) 1.7 ; set xb(2)
2.0
        vector create yb(3) ; set yb(0) 1.7 ; set yb(1) 1.4 ; set yb(2)
1.3

        xb sort yb

        graph .graph
        pack .graph
        proc trace_xa { val } {
                global xb yb xa ya za
                set xa(0) $val
                spline natural   xb yb xa ya
                spline quadratic xb yb xa za
                puts "trace $xa(0)  nat: $ya(0)  quad: $za(0)"
        }

        scale .sc -from 1.4 -to 2.0 -command trace_xa  -orient
horizontal
-resolution 0
        pack .sc -fill x

        .graph element create Aquad -x xa -y za -symbol circle -color
blue
        .graph element create Anat  -x xa -y ya -symbol circle -color
red

        .graph element create B -x xb -y yb -symbol square

        .graph element create Bquad -x xb -y yb -symbol square -color
"darkblue" -smooth quadratic
        .graph element create Bnat -x xb -y yb -symbol square -color
"darkred"
-smooth natural

Quote:
}

Aqad Dot should follow the Bquad curve (
        small error in first leg,
        very big error -oo? in second leg,
        with ~20 samples the glitch happens at about the fourth from the
end
)

Anat Dot should follow the Bnat curve  ( works OK )

G!
UK
--

KLEIN MESSGERAETE Habertwedt 1
D-24376 Groedersby b. Kappeln, GERMANY
phone: +49 4642 920 123 FAX: +49 4642 920 125



Wed, 27 Nov 2002 03:00:00 GMT  
 BLT: bug? in spline: spline natural/quadratic

Quote:

> Hi,

> The spline function used on a destination vector of length 1
> sets "funny" values for spline quadratic vsrc(>3) vdest(1)

> I use the "spline" to do a table lookup for linearisation of a sensor
> transfer function.
> the reference vector has allways 3 or more elements and i use a vector
> of length:1 to interpolate my input value to an output value.

> Script for testing
> bltvector.tcl {
>         package require BLT
>         namespace import blt::*

>         vector create xa(1) ; set xa(0) 1.55
>         vector create ya(1) ; set ya(0) 1.6
>         vector create za(1) ; set za(0) 1.6
>         vector create xb(3) ; set xb(0) 1.4 ; set xb(1) 1.7 ; set xb(2)
> 2.0
>         vector create yb(3) ; set yb(0) 1.7 ; set yb(1) 1.4 ; set yb(2)
> 1.3

>         xb sort yb

>         graph .graph
>         pack .graph
>         proc trace_xa { val } {
>                 global xb yb xa ya za
>                 set xa(0) $val
>                 spline natural   xb yb xa ya
>                 spline quadratic xb yb xa za
>                 puts "trace $xa(0)  nat: $ya(0)  quad: $za(0)"
>         }

>         scale .sc -from 1.4 -to 2.0 -command trace_xa  -orient
> horizontal
> -resolution 0
>         pack .sc -fill x

>         .graph element create Aquad -x xa -y za -symbol circle -color
> blue
>         .graph element create Anat  -x xa -y ya -symbol circle -color
> red

>         .graph element create B -x xb -y yb -symbol square

>         .graph element create Bquad -x xb -y yb -symbol square -color
> "darkblue" -smooth quadratic
>         .graph element create Bnat -x xb -y yb -symbol square -color
> "darkred"
> -smooth natural
> }

> Aqad Dot should follow the Bquad curve (
>         small error in first leg,
>         very big error -oo? in second leg,
>         with ~20 samples the glitch happens at about the fourth from the
> end
> )

Thanks for reposting this.  I lost the original message.

You're right.  The quadratic spline doesn't handle a vector of a single
point (like it intuitively should).   The code I have is wrong.  The only
question is whether I broke it (in my fortran to C translation) or if it
never worked correctly.  You've also prompted me to go to netlib and check
out more spline interpolation routines.

The only work around I can offer right now is to fill the vector with
extra data points, but use only the point you care about.

--gah



Wed, 27 Nov 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. quadratic splines

2. bug fixed in "Handy" Spline Editor

3. Splines in APL

4. Interpolatory Splines from TSPACK for J

5. IMAQ spline interpolation shows artefacts.

6. Cubic spline interpolation

7. Splines in FORTH

8. B-Spline or Bezier coded in Forth ?

9. Spline function in Gadgets

10. Splines, NURBS, B├ęzier curves

11. How to create splines

12. Interactive B-spline (tutorial)

 

 
Powered by phpBB® Forum Software