n=$counter
math=0
plot=0
draw=1
questiontype=0
rows=8
colls=25
checkfile=$checkdir/coord.proc
!if $level=0
    R=$counter
!else
    R=$level
!endif  

var1=x
var2=!randitem f,g,h,k
var3=!randitem j,m,n,s,t,v,w
wims_rawmath_variables=$var1

kleuren=red@rooie,blue@blauwe,green@groene,orange@oranje,purple@paarse
kleuren=!shuffle $kleuren
k1=!item 1 of $kleuren
k2=!item 2 of $kleuren
k1=!replace internal @ by , in $k1
k2=!replace internal @ by , in $k2
kleur1=!item 2 of $k1
color1=!item 1 of $k1
kleur2=!item 2 of $k2
color2=!item 1 of $k2

!if $R=1
    xmin=-5
    xmax=5
    ymin=-80
    Ymax=80
#snijpunt met de simpelste horziontale lijn 
    a=!randitem -3,-2,2,3
    b=!randitem 2,3,4,6,8,10
    pm=!randitem +,-
    x1=!randitem -4,-3,-2,-1
    x2=$[-1*$x1]
    y1=$[$a*$x1*$x1 $pm $b ]
    y2=$y1
    parabool=$a\cdot x^2  $pm $b
    curve1=$a*x^2 $pm $b
    punten=points red,$x1,$y1,$x2,$y2
    curve2=$y1
    lijn=$y1
    answer$n=$x1,$y1,$x2,$y2
 !goto READY
!endif

!if $R=2 or $R=3
    xmin=-10
    xmax=10
    ymin=-100
    Ymax=100
    b=!randitem 2,3,4,5
    pm=!randitem +,-
    x1=!randitem -9,-8,-7,-6,-5,-4,-3,-2,-1
    !if $R=2
	x2=$[-1*$x1]
    !else
	x2=!randitem 1,2,3,4,5,6,7,8,9
    !endif
    y1=$[$x1*$x1 $pm $b*$x1 ]
    y2=$[$x2*$x2 $pm $b*$x2 ]
    parabool=x^2 $pm $b\cdot x
    curve1=x^2 $pm $b*x
    punten=points red,$x1,$y1,$x2,$y2
    tussen=!exec pari ((($y1)-($y2))/(($x1)-($x2)))*x + ($y1) -($x1)*(($y1)-($y2))/(($x1)-($x2))\
    printtex((($y1-$y2)/($x1-$x2))*x + $y1 -$x1*($y1-$y2)/($x1-$x2)) 
    curve2=!line 1 of $tussen
    lijn=!line 2 of $tussen
    answer$n=$x1,$y1,$x2,$y2

 !goto READY
!endif
!if $R>3
#bolleboosjes
    xmin=-7
    xmax=7
    ymin=-300
    Ymax=300
    b=!randitem 2,3,4,5
    a=!randitem 2,3,4,5,-2,-3,-4,-5
    c=!randitem 4,6,8,10,12
    pm=!randitem +,-
    x1=!randitem -6,-5,-4,-3,-2,-1
    !if $R=1
	x2=$[-1*$x1]
    !else
	x2=!randitem 1,2,3,4,5,6
    !endif
    y1=$[$a*$x1*$x1 $pm $b*$x1 - $c ]
    y2=$[$a*$x2*$x2 $pm $b*$x2 -$c ]
    parabool=$a\cdot x^2 $pm $b\cdot x - $c
    curve1=$a*x^2 $pm $b*x - $c
    punten=points red,$x1,$y1,$x2,$y2
    tussen=!exec pari ((($y1)-($y2))/(($x1)-($x2)))*x + ($y1) -($x1)*(($y1)-($y2))/(($x1)-($x2))\
    printtex((($y1-$y2)/($x1-$x2))*x + $y1 -$x1*($y1-$y2)/($x1-$x2)) 
    curve2=!line 1 of $tussen
    lijn=!line 2 of $tussen
    answer$n=$x1,$y1,$x2,$y2
!endif

:READY
!if $image=1 or $teaching=1
    XSIZE=160
    YSIZE=160
    plaatje=$XSIZE,$YSIZE\
    transparent white\
    xrange $xmin,$xmax\
    yrange $ymin,$Ymax\
    linewidth 1\
    vline 0,0,blue\
    hline 0,0,blue\
    linewidth 2\
    curve $color1,$curve1\
    curve $color2,$curve2\
    linewidth 8\
    $punten\
    text black,$[0.8*$xmax],$[0.05*$ymin],normal,$var1-axis\
    textup black,$[0.1*$xmin],$[0.8*$Ymax],normal,y-axis
    
    !if $printexo=0
	image$n=$plaatje
	draw=1
	plot=0
	helptext=$empty
	exotext=$empty
	ss=!record 19 of lang/remarks.$taal
    !else
	ss=!record 18 of lang/remarks.$taal
	helptext=!record 63 of $remarkdir/commonremarks.$taal
	#@ Hier</a> staat een klein grafiekje van de functie
	insdraw_size=$XSIZE,$YSIZE
	!insdraw $plaatje
	#helptext=<a href="javascript:showimage();">$helptext
	helptext=<a onmouseover="this.T_OPACITY=85;this.T_PADDING=10;this.T_WIDTH=$XSIZE;this.T_BORDERCOLOR='gold';this.T_BORDERWIDTH=1;return escape('<img src= $wims_ref_name?&session=$session&module=$module&cmd=getins&special_parm=insert-1.gif>')"><font color=blue>$helptext</font>
        #helptext=<a onmouseover="return escape('<img src= $wims_ref_name?&session=$session&module=$module&cmd=getins&special_parm=insert-1.gif>')"><font color=blue>$helptext</font>
    !endif
!endif

formula$n=\left[ \begin{array}{l}$var2 \left( $var1 \right )\,\,=\,\, $parabool \\ \\ $var3 \left( $var1 \right) \,\,=\,\, $lijn \end{array}\right.
question$n=$ss
rr=!record 20 of of lang/remarks.$taal
textanswer$n=$ss<br>$rr
