Intended to detect impossible shearing situation
obj inscope canvaseditor proc distToLine {x0 y0 x1 y1 x2 y2} {
# calc distance of dot (x2 y2) to line (x0 y0 x1 y1)
if {
($x0 == $x1 && $y0 == $y1) ||
($x2 == $x1 && $y2 == $y1) ||
($x0 == $x2 && $y0 == $y2)
} then {
return 0.0
}
set phi [expr {-(atan2($y1-$y0, $x1-$x0))}]
lappend triangle\
{*}[rotate $x0 $y0 $phi $x0 $y0]\
{*}[rotate $x1 $y1 $phi $x0 $y0]\
{*}[rotate $x2 $y2 $phi $x0 $y0]
lassign $triangle left - right - - -
set width [expr {abs($left - $right)}]
lassign $triangle - bottom - - - top
set height [expr {abs ($top - $bottom)}]
}
© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z