## Introduction

gold 17Jul2010, Here is some starter code for Example Linear Interpolation Calculator written in eTCL. This eTCL script calls on console show, which can act funny on other TCL interpreters.

For the report button, the linear interpolation function takes two known points on a line and solves for an intermediate point. The points are xx1,yy1 xx2,yy2 and xx3,?yy3? The input order of the five items is xx1 yy1 xx2 yy2 xx3 and solving for ?yy3?. The interpolation function loaded as proc pol. User should be able to write pol 50. 1000. 200. 1200. 150. and save answer (1133.3) on console.

## Screenshots Section

gold Changes.

The easiest way to do interpolation of _any_ kind of transfer is via blt vector. Describe your transfer via a pair of x/y vectors and use the blt_spline function to interpolate to a pair of single item vectors sx/sy see interpolation via blt::vector. UK

## appendix TCL programs

### Pretty Print VERSION

```# pretty print version from autoindent and ased
# written on Windowws XP on eTCL
# working under TCL version 8.5.6 and eTCL 1.0.1
# gold on TCL WIKI , 17Jul2010
package require Tk
frame .frame -relief flat -bg aquamarine4
pack .frame -side top -fill y -anchor center

set names {{} x1: y1: {x3:} {y3:} {x2:} {answer:} possible:}
foreach i {1 2 3 4 5 6 } {
label .frame.label\$i -text [lindex \$names \$i] -anchor e
entry .frame.entry\$i -width 35 -textvariable side\$i
}

set msg "Calculator for linear interpolation.\nfrom TCL WIKI,\nwritten on eTCL "
}

proc pi {} {expr acos(-1)}

proc interlinear { xx1 yy1 xx3 yy3 xx2 } {
return [expr { (((\$xx2-\$xx1)*(\$yy3-\$yy1))/(\$xx3-\$xx1))+ \$yy1 } ] }

proc pol { xx1 yy1 xx3 yy3 xx2 } {
return [expr { (((\$xx2-\$xx1)*(\$yy3-\$yy1))/(\$xx3-\$xx1))+ \$yy1 } ] }

proc calculate {     } {
global side1 side2 side3 side4 side5 side6
set answer2 [ interlinear  \$side1 \$side2 \$side3 \$side4 \$side5  ]
set pi5 [pi]
#\$x insert 1.0 " % error \$error5 "
#\$t insert 1.0 " % error  \$error5 "
}

proc fillup {aa bb cc dd ee ff} {
.frame.entry1 insert 0 "\$aa"
.frame.entry2 insert 0 "\$bb"
.frame.entry3 insert 0 "\$cc"
.frame.entry4 insert 0 "\$dd"
.frame.entry5 insert 0 "\$ee"
.frame.entry6 insert 0 "\$ff"
}

proc clearx {} {
foreach i {1 2 3 4 5 6} {
.frame.entry\$i delete 0 end
}
}

proc reportx {} {
console show
puts "
The interpolation function takes
two know points on a line and
solves for an intermediate point.
The points are xx1,yy1   xx2,yy2 and xx3,?yy3?
The input order of the five items
is xx1 yy1 xx2 yy2 xx3
and solving for ?yy3?.
proc pol. User should be able to write
pol 50. 1000. 200. 1200.  150.
and save answer (1133.3)  on console."
}

frame .buttons -bg aquamarine4

::ttk::button .calculator -text "Solve" -command calculate
::ttk::button .test2 -text "Testcase1" -command { clearx;fillup 10.  100.  60.  120.   50.  116 }
::ttk::button .test3 -text "Testcase2" -command { clearx;fillup 50.  1000. 200. 1200.  150. 1133 }
::ttk::button .test4 -text "Testcase3" -command { clearx;fillup 200. 1000. 300. 1500.  250. 1250}
::ttk::button .clearallx -text clear -command clearx
::ttk::button .cons -text report -command reportx
::ttk::button .exit -text exit -command exit

pack .clearallx .cons .about .exit .test4 .test3 .test2 -side bottom -in .buttons
grid .frame .buttons -sticky ns -pady {0 10}
. configure -background aquamarine4 -highlightcolor brown -relief raised -border 30
wm title . "Linear Interpolation Calculator"

```