Version 3 of Example Linear Interpolation Calculator

Updated 2010-07-17 23:46:57 by gold

Example Linear Interpolation Calculator


This page is under development. Comments are welcome, but please load any comments in the comments section at the middle of the page. Thanks,gold



 Here is some starter code for Example Linear Interpolation Calculator. 
    The Iching is the       

  1. prevailing conditions

   ----
    ----


 ----
  With the buttons in the little canvas demo, one can call up
  separate routines to lay out the different
   boards and install the various options  .
  In a teamwork situation, programming teams could divide up
 the several tasks with the framework. In many cases, it
 is advantageous to have or write little demo programs for
 the separate subroutines. Some of the demo code decks are
 included below.
  In the button call up of the canvas demo, separate tasks
  can laid in successive
  statements to clear board, set states, layout the board, and
  populate the chesspieces. Loading four statements in the button
   might be ClrCanvas .cv; set state3 3;board .cv;
  This gets a little lengthy for a button line, so these statements could 
  be stacked in a separate subroutine. With some global statements for
  any constants and passing the canvas name as $w, the  subroutine
   could be written like 
  proc stackedlist (w) (
  global state3
  ClrCanvas $w; 
  set state3 3;
  board $w;
     ]












Screenshots Section


Comments Section

         Please place any comments here, Thanks.

gold Changes.

----
**References***

  
  
**appendix TCL programs**



***FIRST VERSION*** 
       proc positionWindow w {
    wm geometry $w +300+300
    }
      set font  {Helvetica 18}
  
       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
    grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1
     }
  proc about {} {
    set msg "Calculator for linear interpolation.
          from TCL WIKI,
          written on eTCL "
    
    tk_messageBox -title "About" -message $msg
 }
     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 colorwarning
    global colorback
    global answer2   answer3
    global side1 side2 side3 side4 side5 side6 
       set answer2 ""
   
   
   set answer2  [ interlinear  $side1 $side2 $side3 $side4 $side5  ] 

   set side6 $answer2  

   
      set pi5 [pi]
   if {$answer2 >= $pi5} { set error5   [expr {100.*$answer2/$pi5-100.}]   }
   if {$answer2 <= $pi5} { set error5   [expr {100.*$pi5/$answer2-100.}]   }
   #$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?.
   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."
   }


  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 .about -text about -command about
    ::ttk::button .cons -text report -command { reportx }
    ::ttk::button .exit -text exit -command {exit}
    pack .calculator  -in .buttons -side top -padx 10 -pady 5
     
    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
    bind . <Motion> {wm title . "Linear Interpolation Calculator"}







*SECOND VERSION WITH ADDED HACKS

     #start of deck#!/bin/sh
  

    #end of deck
    #end of deck
      #end of deck
      #end of deck      
      #end of deck
    #end of deck


****Version with added hacks ****




   proc positionWindow w {
    wm geometry $w +300+300
   }
   set font  {Helvetica 18}
  set colorgrd seashell4
 set colorback bisque
 set colorwarning tomato1
    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
    grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1
   }
  proc about {} {
    set msg "Calculator for linear interpolation.
          from TCL WIKI"
    
    tk_messageBox -title "About" -message $msg
    }
     proc pi {} {expr acos(-1)}
   
   proc interlinear { xx1 yy1 xx3 yy3 xx2   } {
     return [expr {  ((($xx2-$xx1)*($yy3-$yy1))/($xx3-$xx1))+ $yy1 } ] ;}

    proc calculate {     } {
    global colorwarning
    global colorback
    global answer2   answer3
    global side1 side2 side3 side4 side5 side6 
       set answer2 ""
   
   
   set answer2  [ interlinear  $side1 $side2 $side3 $side4 $side5  ] 

   set side6 $answer2  

   
      set pi5 [pi]
   if {$answer2 >= $pi5} { set error5   [expr {100.*$answer2/$pi5-100.}]   }
   if {$answer2 <= $pi5} { set error5   [expr {100.*$pi5/$answer2-100.}]   }
   #$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
    }
     }


  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 .about -text about -command about
    ::ttk::button .exit -text exit -command {exit}
    pack .calculator  -in .buttons -side top -padx 10 -pady 5
     
    pack  .clearallx .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
    bind . <Motion> {wm title . "Linear Interpolation Calculator"}
    #start of deck
        #start of deck
        #start of deck 
       

    #end of deck
    #end of deck
   #end of deck
   #end of  deck
   #end of deck
   #end of deck
    #end of deck