**Parametric Equation Model Vaporware TCL Calculator**

This page is under development. Constructive comments are welcome, but please load any constructive comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, [gold] 10Oct2020
----

<<TOC>>
***Preface***
----
[gold] Here are some TCL calculations for Parametric Equation Model Vaporware in calculator shell. This is a display mock up or vaporware program with dummy parametric calculations.. 
----
***Introduction*** 
 
----
[gold] 10/3/2020 Forwarding offline request to Ask13 page. Will take me some time to find references, but maybe our other members have something to say.
----
9/29/2020. Hi everyone, I should apply to at my parametric model a list of values (w_list) with cycle for. In each step the code must set 3 coefficients (k1,k2,k3)
======
set w_list [list {0.12} {0.14} {0.16} {0.18} {0.20}];
set k1_list [list {1.080} {1.101} {1.123} {1.144} {1.166}];
set k2_list [list {1.116} {1.213} {1.260} {1.309} {1.360}];
set k3_list [list {1.915} {2.157} {2.402} {2.649} {2.898}];
At the moment I put only this string:
for {set index4 0} {$index4<[llength $w_list]} {incr index4} {
set w [lindex $w_list $index4]
======
----
How can I continue?
----[gold] 10/01/2020. Look up model program on Timing Equivalent One Liners V2 at the bottom of the file One Liners Programs Compendium and TCL demo examples calculations, numerical analysis. I do not load braces around elements for computations, set k1_list {list  1.080  1.101   1.123  1.144 1.166 }, but there are many possible list formats, I guess. Suggest morf this parametric equation into  graphical user interface gui that one could use. equation+of+rotated+ellipse from [GS] is maybe simple. But rotated-ellipse code looks fairly robust here and the display might be a step up. Not sure what your >> application<< is, but one could probably use a slot calculator 1) window for numeric entries controlling the calculation proc and the 2) graphics display windows. Data transfer in vaporware uses global variables. The slot calculators have 8 slots. The calculation proc supplies 5 parameters from dummy number calculations to the ellipsoidal  parametric equations. The calculation proc uses a for loop, as you requested.  Suggest check out pages or websites of  [GS] and [uniquename]   10/02/2020 sic. Forwarded your query to the TCL Wiki on ASK 13 page . This TCL Wiki on ASK 13 page is easier <for me> to type and format an answer. [gold] 10/03/2020. What is your application? What system are you trying to model, bio, engr design, geometry, or physics? Check below link [uniquename]. This seems crack beyond what I have done. [gold] 10/7/2020, Individual could not be contacted and/or answer for further feedback. Loaded available contributions on new wiki page. Further wiki contributions welcomed on new page, but believe the abundant references on wiki are suitable, if applied.
----[gold] 10/03/2020. What is your application? What system are you trying to model, bio, engr design, geometry, or physics? Check below link [uniquename]. This seems crack beyond what I have done.
----
[gold] 10/7/2020, Individual could not be contacted and/or answer for further feedback. Loaded available contributions on new wiki page. Further wiki contributions welcomed on new page, but believe the abundant references on wiki are suitable, if applied.
----

References.
----
   * [https://wiki.tcl-lang.org/.../A+3D+Generator-and-Examiner...
   * [A 3D Generator-and-Examiner for Parametric Surfaces of 2 Variables]
   * [foreach]
   * [I love foreach]
   * [for]
----
----
 
  
*** Discussion  ***
---- 

 
----
*** Conclusions ***
---- 
 
The TCL calculator seems to be working as it stands.  


----
 


----
** ScreenShot Section **
----
***Figure 1 , Parametric Model Mockup Display***
----
[new page ask13]
----
***Figure 2 , Sample of plain calculator***
----
[bablylonian_trapezoid_cal]

----
**Appendix Code**

***appendix TCL programs and scripts ***
----
 

======
        # pretty print from autoindent and ased editor
        # Parametric Model Vaporware   V2
        # written on Windows 10 on TCL
        # working under TCL version 8.6
        # gold on  TCL Club, 4Oct2020
        # charting based on rotated ellipse by Gerard Sookahet
        # gold added push buttons calculatorand housekeeping 
        # using dummy calculations for parametric eq. calc.    
        package require Tk
        package require math::numtheory
        # added statements for TCLLIB library
        package require math::numtheory
        package require math::constants
        package require math::trig
        package require math
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
        # Tried to keep clean GS  code in upper section
        set tcl_precision 17
        proc pie {} {expr acos(-1)} ;# AMG
        # Section EllipseRotate  
        # Section proc EllipseRotate Author:Gerard Sookahet
        # Description: Simple graphical example of parametric equation of rotated ellipse
        #
        # xo,yo : center of the ellipse
        # angle : rotation angle from 0 to 7 with the scalebar
        # a : major radius
        # b : minor radius
        # t : parameter
        bind all <Escape> {exit}
        #  proc Author       Gerard Sookahet
        proc EllipseRotate {xo yo a b angle t} {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            set cosa [expr {cos($angle)}]
            set sina [expr {sin($angle)}]
            set cost [expr {cos($t)}]
            set sint [expr {sin($t)}]
            set x [expr {$xo + $a*$cosa*$cost - $b*$sina*$sint}]
            set y [expr {$yo + $a*$sina*$cost + $b*$cosa*$sint}]
            return [list $x $y]
        }
        proc EllipsePlot {w xo yo a b pi angle} {
            $w delete all
            lassign [EllipseRotate $xo $yo $a $b $angle 0] x2 y2
            for {set p 0} {$p <= 720} {incr p} {
                set t [expr {$pi*$p/360}]
                lassign [EllipseRotate $xo $yo $a $b $angle $t] x1 y1
                .c create line $x1 $y1 $x2 $y2 -fill blue -width 3
                set x2 $x1
                set y2 $y1
            }
        }
        # fallback settings
        #set width 600
        #set height 400
        set width 800
        set height 500
        set pi 3.1415926
        set xo [expr {$width/2}]
        set yo [expr {$height/2}]
        set a 200
        set b 100
        set angle [expr {$pi/6}]
        #pack [canvas .c -width $width -height $height -background black]
        #pack [scale .sc -from 0 -to 7 -length 240 -resolution .1 \
                -orient horiz -bd 1 -showvalue true -variable angle \
                -command {EllipsePlot .c $::xo $::yo $::a $::b $::pi}]
        package require Tk
        package require math::numtheory
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
        set tcl_precision 17
        frame .frame -relief flat -bg aquamarine4
        pack .frame -side top -fill y -anchor center
        set names {{} {parameter 1:} }
        lappend names {parameter 2:}
        lappend names {parameter 3:}
        lappend names {parameter 4:}
        lappend names {parameter 5:}
        lappend names {parameter 6:}
        lappend names {parameter 7:}
        lappend names {parameter 8:}
        foreach i {1 2 3 4 5 6 7 8} {
            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 Parametric Model Vaporware   V2
            from TCL ,
            # gold on  TCL Club, 10Jul2020 "
            tk_messageBox -title "About" -message $msg }
        proc self_help {} {
            set msg "Calculator for Parametric Model Vaporware V2
            from TCL ,
            # self help listing
            # 4 givens follow.
            # 1) parameter 1:
            # 2) parameter 1:
            # 3) parameter 1: 
            # 4) parameter 1:
            # Recommended procedure is push testcase and fill frame,
            # change first three entries etc, push solve,
            # and then push report. Report allows copy and paste
            # from console to conventional texteditor. For testcases
            # testcase number is internal to the calculator and
            # will not be printed until the report button is pushed
            # for the current result numbers.
            # This posting, screenshots, and TCL source code is
            # copyrighted under the TCL/TK 8.6 license terms.
            # Editorial rights retained under the TCL/TK license terms
            # and will be defended as necessary in court.
            # gold on  TCL Club, 2Oct2020 "
            tk_messageBox -title "About" -message $msg }
        #  uses join, but computer time on some?
        proc mean_1  list {expr double([join $list +])/[llength $list]}
        # math operators exposed as commands, and the expand operator
        # math operators exposed as commands, and the expand operator
        proc mean_2  list {expr {[tcl::mathop::+ {*}$list]/double([llength $list])}}
        #  import the tcl::mathop operators
        proc mean_3 list {expr {[+ {*}$list]/double([llength $list])}}
        #  import the tcl::mathop operators from <Summing a list>
        proc table_calc {value} {
        # computer drag time sensitive on limit variable
        set limit 3
        # should apply to at my parametric model
        # a list of values (w_list) with cycle for.
        # In each step the code must set 3 coefficients (k1,k2,k3)
        # copy original format internet query
        set w_list [list  0.12   0.14   0.16   0.18   0.20 ];
        set k1_list [list {1.080} {1.101} {1.123} {1.144} {1.166}];
        set k2_list [list {1.116} {1.213} {1.260} {1.309} {1.360}];
        set k3_list [list {1.915} {2.157} {2.402} {2.649} {2.898}];
        # gold does not use braces around list elements, left as original 
        # copy of original format in internet query
        # setting table of dummy calculations
        # with data supplied in internet query
        puts "%|table| | printed in|TCL format |% "
        puts "&| session| proc &  mean value| elements in list  | comment, if any|& "
        for { set i 0 } { $i <= $limit }  { incr i } {
            # may leave redundant or fallback statements in draft program
            # set lister { 1 2 4 5 6 7 8 9 10 }
            set lister { 0.12   0.14   0.16   0.18   0.20 }
            lappend lister  [* $i [pie]]
            puts "&|$i | mean_1   [ mean_1  $lister ]| $lister |  $k1_list |   [ mean_1  $k1_list ]  |&"
            puts "&|$i | mean_2   [ mean_2  $lister ]| $lister |  $k2_list |   [ mean_2  $k2_list ]  |&"
            puts "&|$i | mean_3   [ mean_3  $lister ]| $lister |  $k2_list |   [ mean_3  $k3_list ]  |&"
        }}
        proc calculate {     } {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global testcase_number
            incr testcase_number
            set side1 [* $side1 1. ]
            set side2 [* $side2 1. ]
            set side3 [* $side3 1. ]
            set side4 [* $side4 1. ]
            set side5 [* $side5 1. ]
            set side6 [* $side6 1. ]
            set side7 [* $side7 1. ]
            set side8 [* $side8 1. ]
            set side5 1.
            set side6 1.
            set side7 1.
            set side8 1.
            table_calc 1
            set w_list [list  0.12   0.14   0.16   0.18   0.20 ] 
            set velocity_0 $side1
            set velocity_1 $side2
            set base_line [ expr { abs (  $side4 - $side3 )} ]
            set calculation_1 [ expr { .5 * ( $side1 + $side2 ) * 60. } ]
            set bisection_1 [ expr { .5 * $calculation_1 } ]
            set bisection_velocity_c [ expr {  ((($velocity_0)**2 +($velocity_1)**2)/2.)**.5 }]
            set bisection_time_c [ expr { $base_line * (  $velocity_0 -  $bisection_velocity_c  ) /  ( $velocity_0 -  $velocity_1  )  }]
            set side5 $bisection_velocity_c
            set side6 $bisection_1
            set side7 $bisection_time_c
            set side8 $calculation_1
            set side1 [* $side1 100. ]
            set side2 [* $side2 100. ]
            set side3 [* $side3 100. ]
            set side4 [* $side4 100. ]
            set side5 [* $side5 100. ]
            set side6 [* $side6 100. ]
            set side7 [* $side7 100. ]
            set side8 [* $side8 100. ]
        }
        proc fillup {aa bb cc dd ee ff gg hh} {
            .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"
            .frame.entry7 insert 0 "$gg"
            .frame.entry8 insert 0 "$hh"
        }
        proc clearx {} {
            foreach i {1 2 3 4 5 6 7 8 } {
                .frame.entry$i delete 0 end } }
        proc reportx {} {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global testcase_number
            console show;
            console eval {.console config -bg palegreen}
            console eval {.console config -font {fixed 20 bold}}
            console eval {wm geometry . 40x20}
            console eval {wm title . " Parametric Model Vaporware  V2 Report , screen grab and paste from console 2 to texteditor"}
            console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}
            puts "%|table $testcase_number|printed in| tcl format|% "
            puts "&| quantity| value| comment, if any|& "
            puts "&| $testcase_number:|testcase_number | |&"
            puts "&| $side1 :|parameter 1: |   |&"
            puts "&| $side2 :|parameter 2: | |& "
            puts "&| $side3 :|parameter 3: | |& "
            puts "&| $side4 :|parameter 4: | |&"
            puts "&| $side5 :|parameter 5:| |  |&"
            puts "&| $side6 :|parameter 6:| |  |&"
            puts "&| $side7 :|parameter 7:| |  |&"
            puts "&| $side8 :|parameter 8:| |  |&"
            
        }
        frame .buttons -bg aquamarine4
        ::ttk::button .calculator -text "Solve" -command { calculate   }
        ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 1.080 1.101 1.123  1.144  1.116 1.0  1.0  1.0 }
        ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 1.116 1.213  1.260  1.309  1.360 1.0  1.0  1.0 }
        ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 1.915 2.157 2.402  2.649  2.649 1.0  1.0  1.00  }
        ::ttk::button .clearallx -text clear -command {clearx }
        ::ttk::button .about -text about -command {about}
        ::ttk::button .self_help -text self_help -command {self_help}
        ::ttk::button .console2 -text report -command { reportx }
        ::ttk::button .exit -text exit -command {exit}
        canvas .c -width $width -height $height -background black
        scale .sc -from 0 -to 7 -length 240 -resolution .1 \
                -orient horiz -bd 1 -showvalue true -variable angle \
                -command {puts " display scale $side1 $side2 $side3 $side4 [pie]"; EllipsePlot .c $side1 $side2 $side3 $side4 [pie]}
        pack .c .sc .calculator -in .buttons -side top -padx 10 -pady 5 
        pack  .clearallx .console2 .self_help .about .exit .test4 .test3 .test2   -side left -in .buttons
        grid .frame .buttons -sticky ns -pady {0 10}
        . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30
        wm title . " Parametric Model Vaporware V2"
        # gold on TCL Club, 8Jul2020
        # This posting, screenshots, and TCL source code is
        # copyrighted under the TCL/TK 8.6 license terms.
        # Editorial rights retained under the TCL/TK license terms
        # and will be defended as necessary in court.
        # end of file
======
----
 
----
*** Pushbutton Operation***

For the push buttons, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console. 

For  testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button.   The command { calculate; reportx  } or { calculate ; reportx; clearx  } can be added or changed to report automatically. Another wrinkle would be to print out the current text,  delimiters,  and numbers in a TCL wiki style table as

======
  puts " %| testcase $testcase_number | value| units |comment |%"
  puts " &| volume| $volume| cubic meters |based on length $side1 and width $side2   |&"  
======
 
----
[gold] This page is copyrighted under the TCL/TK license terms, [http://tcl.tk/software/tcltk/license.html%|%this license]. 

**Hidden Comments Section**

<<discussion>>
Please place any comments here, Thanks.

                              
<<categories>> Numerical Analysis | Toys | Calculator | Mathematics| Example| Toys and Games | Games | Application | GUI

<<categories>> Development | Concept| Algorithm