proc testCase1 {edgeCoords vertices} {
   set x1 [lindex $edgeCoords 0]
   set y1 [lindex $edgeCoords 1]

   set x0 [lindex $vertices 0]
   set y0 [lindex $vertices 1]

   set rad2deg [expr 180 / 3.141592654]

   set x1_sq [expr $x1 * $x1]
   set y1_sq [expr $y1 * $y1]
   set x0_sq [expr $x0 * $x0]

#  puts "x0 = $x0, x0^2 = $x0_sq"
#  puts "x1 = $x1, x1^2 = $x1_sq"
#  puts "y1 = $y1, y1^2 = $y1_sq"

   set denominator [expr 1.0 / ($x1_sq + $y1_sq)]
#  puts "$x1_sq + $y1_sq = [expr $x1_sq + $y1_sq]"
#  puts "denominator = $denominator"

   set factor1 [expr -1 * $x0_sq + $x1_sq + $y1_sq]
#  puts "factor1 = $factor1"

   set x0x1 [expr $x0 * $x1]
#  puts "x0x1 = $x0x1"

   if {$factor1 > 0.0} {
      set y1_sqrt_factor1 [expr $y1* sqrt($factor1)]

#     puts "$x0x1 - $y1 * sqrt($factor1) = [expr $x0x1 - $y1_sqrt_factor1]"
#     puts "$x0x1 + $y1 * sqrt($factor1) = [expr $x0x1 + $y1_sqrt_factor1]"

      # have to split up the expr; otherwise, acos failed
	  set factor2 [expr ($x0x1 - $y1_sqrt_factor1) * $denominator]
	  set factor3 [expr ($x0x1 + $y1_sqrt_factor1) * $denominator]

#     puts "($x0x1 - $y1 * sqrt($factor1)) * $denominator = $factor2"
#     puts "($x0x1 + $y1 * sqrt($factor1)) * $denominator = $factor3"

#     puts "acos(($x0x1 - $y1_sqrt_factor1) * $denominator)) = [expr acos($factor2)]"
#     puts "acos(($x0x1 + $y1_sqrt_factor1) * $denominator)) = [expr acos($factor3)]"

      set angles1 [list [expr -1 * acos($factor2)] [expr acos($factor2)] \
         [expr -1 * acos($factor3)] [expr acos($factor3)]]

      puts "angles1 - $angles1"

      # have to split up the expr; otherwise, acos failed
	  set factor2 [expr acos(($x0x1 - $y1_sqrt_factor1) * $denominator)]
	  set factor3 [expr acos($x0x1 + $y1_sqrt_factor1) * $denominator)]

      set angles2 [list [expr -1 * $factor2] [expr $factor2] \
         [expr -1 * $factor3] [expr $factor3]]

      puts "angles2 - $angles2"
   } else {
      ::error "failed to compute angle"
   }
}

testCase1 [list -1792.986000 -1792.986000] [list -1792.986000 -1792.986000]
