# Definition of an exercise ruler & compass.
# syntax of the file.
# points:  each line defines a point.  x,y
# lines:   each line defines two points on a line.   x1,y1,x2,y2,type
#          type: 1 (segment), 2 (line), 3 (semiline direct), 4 (semiline inverse)
#	   type is facultative, defaulting to 1.
# circles: each line defines a circle. x,y,r,n
#	   where (x,y) is the center, r=radius,
#          n is the number of point for the center (if n>0).
# goal: each line defines an object. First item is the type of the object
# (point,line or circle), the rest are parameters (same as above).
# goal_text: text explaining the goal. (language-dependent)

title=Ortocentro di un triangolo

a=!random 0,2*pi
a1=!random pi*0.67,pi*1.2
a2=!random $a1+pi/4,(7/4)*pi
b1=$[$a+$a1]
b2=$[$a+$a2]
r=3
x1=$[$r*cos($a)]
y1=$[$r*sin($a)]
x2=$[$r*cos($b1)]
y2=$[$r*sin($b1)]
x3=$[$r*cos($b2)]
y3=$[$r*sin($b2)]
points=$x1,$y1\
$x2,$y2\
$x3,$y3
lines=$x1,$y1,$x2,$y2,1\
$x2,$y2,$x3,$y3,1\
$x3,$y3,$x1,$y1,1

#compute the orthocenter
det=(($x2-$x3)*($y1-$y3)-($x1-$x3)*($y2-$y3))
c1=($x1*($x2-$x3)+$y1*($y2-$y3))
c2=($x2*($x1-$x3)+$y2*($y1-$y3))
x4=((($c1)*($y1-$y3)-($c2)*($y2-$y3))/$det)
y4=((($x2-$x3)*($c2)-($x1-$x3)*($c1))/$det)

goal=point,$x4,$y4
goal_text=trovare l'ortocentro del triangolo 1 2 3
hint=L'ortocentro di un triangolo  il punto comune delle tre altezze. \
Poich le tre altezze passano per uno stesso punto, sar sufficiente \
tracciarne solo due, poi marcare l'intersezione.
solution=circle,1,3#On commence par construire la hauteur du ct 1-2.\
circle,2,3\
point,circle,1,circle,2\
line,3,4#Droite 4 est la hauteur du ct 1-2.\
hide,circle,1\
hide,circle,2\
hide,point,4#Maintenant la hauteur du ct 2-3.\
circle,2,1\
circle,3,1\
point,circle,3,circle,4\
line,1,5#Droite 5 est la hauteur du ct 2-3. On peut dj atteindre le but en marquant l'intersection des deux hauteurs, mais nous allons construire la troisime hauteur aussi.\
hide,circle,3\
hide,circle,4\
hide,point,5\
circle,1,2\
circle,3,2\
point,circle,5,circle,6\
line,2,6#Droite 6 est la hauteur du ct 1-3. L'intersection des trois hauteurs est l'orthocentre.\
hide,circle,5\
hide,circle,6\
hide,point,6\
point,line,4,line,5

