1 puts "======================="
2 puts "Test for Circle/Sphere extrema algorithm"
3 puts "Touch case (circle is just touching the sphere)"
4 puts "======================="
12 sphere s $x0 $y0 $z0 $sph_radius
14 # Initially the circle will be made at the same place as sphere with different radius
15 # and will shifted many times to touch the sphere.
16 # The distance should always be close to zero.
18 # Number of different radius of initial circle
20 # Number of circle's rotations
22 set angle [expr 180. / $nbstep]
27 for {set i 1} {$i < $nb_radius} {incr i} {
28 set circ_radius [expr $i*2.]
29 if {$circ_radius == $sph_radius} {
30 set circ_radius [expr $circ_radius + 0.1]
32 circle c $x0 $y0 $z0 0 0 1 $circ_radius
34 # Circle will be rotated around the line
35 line rotation_line $x0 $y0 $z0 1 0 0
37 for {set j 1} {$j <= $nbstep} {incr j} {
38 rotate rotation_line $x0 $y0 $z0 0 0 1 $angle
40 # Get direction for circle's rotation
41 regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump rotation_line] full dx dy dz
45 for {set k 1} {$k <= $nbstep} {incr k} {
46 rotate c_rotated $x0 $y0 $z0 $dx $dy $dz $angle
48 # Get translation axis for the circle
49 regexp {XAxis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump c_rotated] full dxx dxy dxz
51 # Get rotation plane for translation line
52 regexp {YAxis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump c_rotated] full dyx dyy dyz
54 line translation_line $x0 $y0 $z0 $dxx $dxy $dxz
56 for {set n 1} {$n <= $nbstep} {incr n} {
57 rotate translation_line $x0 $y0 $z0 $dyx $dyy $dyz $angle
59 # Get direction for circle's translation
60 regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump translation_line] full dtx dty dtz
62 # Circle's translation
63 copy c_rotated c_shifted
64 translate c_shifted $sph_radius*$dtx $sph_radius*$dty $sph_radius*$dtz
66 # Shift circle to touch sphere
69 copy c_shifted c_touch
70 translate c_touch $shift*$circ_radius*$dxx $shift*$circ_radius*$dxy $shift*$circ_radius*$dxz
72 set log [extrema c_touch s]
74 # save each circle if necessary
75 # copy c_touch c_$iStep
77 if {![regexp "ext_1" $log]} {
78 if {![regexp "Extrema 1 is point" $log]} {
79 puts "Error: Extrema has not detected the touching case on step $iStep"
81 puts "Check of Step $iStep, min distance OK"
84 set ext_dist [lindex [length ext_1] end]
85 checkreal "Step $iStep, min distance " $ext_dist 0 1.e-7 1.e-7