Ellipse Properties Slot Calculator Example

Ellipse Properties Slot Calculator Example


This page is under development. Comments are welcome, but please load any 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 12Dec2018



Introduction

gold Here is an eTCL script on to estimate ellipse properties. For the push buttons, the recommended procedure is push testcase and fill frame, change first three entries a,b,c with always a>b, push solve, and then push report. Report allows copy and paste from console. c is the third dimension term of ellipsoid and not necessary for ellipse values.

In planning any software, there is a need to develop testcases to test the software. The semimajor axis is called a and the semiminor axis is called b. The approximate perimeter is 2*pi*sqrt((a**2+b**2)/2.) The approximate area is pi*a*b cc is sqrt of term (a**2-b**2) in the code. cc is not used in the initial ellipse calculations, but recalculated from a and b. Always a>b. ---

 Testcase 1. 
 a=50
 b=10
 perimeter=226.4
 area=1570.8
 c=49.
  eccentricity=0.98
 half foci distance=49
  loop length=99
 length between foci    97.97958971132712
 perimeter   226.54346798277953
 area1   1570.7963267948967
  eccentricity   0.9797958971132712    
  ellipsoid surface area   16983.11674576446   
  ellipsoid volume   102625.36001726658 



 Testcase 2.
  a=200
  b=100
  half foci distance c=173.2
  perimeter=993.5
  area=6.28E4
  eccentricity=0.866
  half foci distance=173
  loop length=373
  length between foci    346.41016151377545
 perimeter   993.4588265796102
 area1   62831.853071795864
  eccentricity   0.8660254037844386    
  ellipsoid surface area   310102.2018735903   
  ellipsoid volume   14493214.108560912 

  Testcase 3.
  a=500
  b=250
  c=433. 
  perimeter= 392699.
  area=2483.6
  eccentricity=0.866
  foci distance=433
  loop length=933
  length between foci    346.41016151377545
  perimeter   993.4588265796102
  area1   62831.853071795864
  eccentricity   0.8660254037844386    
  ellipsoid surface area   310102.2018735903   
  ellipsoid volume   14493214.108560912 

 Testcase 4.

  ellipsoid of a,b,c
   11,10,12
  length between foci    9.16515138991168
  perimeter   66.0482031949507
  area1   345.5751918948772
  eccentricity   0.4165977904505309    
  ellipsoid surface area   1518.8976979609918   
  ellipsoid volume   5529.203070318035 



   cc   54.29800248061361
  perimeter   66.0482031949507
  area1   345.5751918948772
  eccentricity   0.4165977904505309    
  ellipsoid surface area   1518.8976979609918   
  ellipsoid volume   5529.203070318035 

Screenshots Section

Ellipse Properties Slot Calculator Example diagram.png

Ellipse Properties Slot Calculator Example screen.png


References:


Appendix Code

appendix TCL programs and scripts


*Pretty Print Version

    #pretty print from autoindent and ased editor
    # ellipse properties
    # written on Windowws XP on eTCL
    # working under TCL version 8.5.6 and eTCL 1.0.1
    # gold on TCL WIKI , 18aug2010
    frame .frame -relief flat -bg aquamarine4
    pack .frame -side top -fill y -anchor center
  set names {{} {semimajor length a:} {semiminor length b:} {ellipsoid length c :} {area:} {length betw. foci:}} 


    foreach i {1 2 3 4 5 6 7} {
        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 Ellipse Properties.
        from TCL WIKI,
        written on eTCL "
        tk_messageBox -title "About" -message $msg
    }
    proc pi {} {expr acos(-1)}
    proc ellipse5 { xx1   } {
        global side1 side2 side3
        global side4 side5 side6 side7
        set ss side1
        set tt $side2
        set cc  [ expr { $side1*$side1- $side2*$side2  } ]
        set cc  [ expr { sqrt($cc)  } ]
        set term1 [ expr { ($side1*$side1+ $side2*$side2) /2.    } ]
        set perimeterx [ expr { 2.*[pi]*sqrt($term1)} ]
        set area1 [ expr { 1.*[pi]*$side1*$side2  } ]
        set xxx [ expr { $side4*[pi]/180.  } ]
        set side4 $area1
        set side5 [expr { 2.* $cc } ]
        set side7  [ expr { 1.*$cc/$side1 } ]
        set rr  [ expr { $cc/$side1 } ]
        #set side7  [ expr { ((2.*[pi] *$side1*$side2)*(1.*$side2/$side1+($side1/$cc)*asin($rr)))} ]
        set side6 $perimeterx
        return $side7
    }
    proc calculate {     } {
        global answer2 
        global side1 side2 side3 side4 side5 side6 side7
        set answer2 5
        set answer2  [ ellipse5  $side1     ]
        set side7 $answer2
    }
    proc fillup {aa bb cc dd ee ff gg} {
        .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 "
    }
    proc clearx {} {
        foreach i {1 2 3 4 5 6 7} {
            .frame.entry$i delete 0 end
        }
    }
    proc reportx {} {
        global side1 side2 side3 side4 side5 side6 side7
        console show;
        puts " "
        set gg  [ expr { $side1*$side1- $side2*$side2  } ]
        set gg  [ expr { sqrt($gg)  } ]
        set cx  [ expr { $side1*$side1- $side2*$side2  } ]
        set cx  [ expr { sqrt($cx)  } ]
        set foci [ expr { 2.*$gg  } ]
        set term1 [ expr { ($side1*$side1+ $side2*$side2) /2.    } ]
        set perimeterx [ expr { 2.*[pi]*sqrt($term1)} ]
        set area1 [ expr { 1.*[pi]*$side1*$side2  } ]
        set  eccentricity  [ expr { 1.*$cx/$side1 } ]
        set pp 1.6075
        set aa  [ expr { pow($side1,$pp) } ]
        set bb  [ expr { pow($side2,$pp) } ]
        set cc  [ expr { pow($side3,$pp) } ]
        set term7  [ expr { ($aa*$bb+$aa*$cc+$bb*$cc)/3.} ]
        set term8  [ expr { 1./1.6075 } ]
        set term7  [ expr { pow($term7,$term8) } ]
        set ellipsoidarea [ expr { 1.*4.*[pi]*$term7  } ]
        set ellipsoidvolume [ expr { 1.*(4./3.)*[pi]*$side1*$side2*$side3 } ]
        puts " length between foci    $foci"
        puts " perimeter   $perimeterx"
        puts " area1   $area1"
        puts "eccentricity   $eccentricity    "
        puts "ellipsoid surface area   $ellipsoidarea   "
        puts "ellipsoid volume   $ellipsoidvolume "
    }
    frame .buttons -bg aquamarine4
    ::ttk::button .calculator -text "Solve" -command { calculate   }
    ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 50. 10. 49. 1570.8  98. 226.5 0.97}
    ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 200. 100. 173. 6.28E4  346. 993. 0.86}
    ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 500. 250. 433. 3.9E5  866. 2483.  0.86 }
    ::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
    wm title . "Ellipse Properties"

Hidden Comments Section

Please place any comments here with your wiki MONIKER and date, Thanks.gold12Dec2018