n=$teller
!if $graad=0
    R=$teller
!else
    R=$graad
!endif 
!if $printbaar =0
    white=white
!else
    white=magenta
!endif        
!if $taal=nl
    onder=onder
    boven=boven
    en=en
!else
    onder=under
    boven=above
    en=and
!endif           
!if $R=1
    bewerking=bewerking1.proc 
    a=!randitem 2,4,6,8,10
    b=!randitem 5,7,9,11,12,14,16,19
    q=!randitem 1,2,3,4,5,6,7,8,9
    p=!randitem 1,2,3,4,5,6,7,8,9
    pm=!randitem +,-
    mp=!randitem +,-
    f=!randitem f,h,k
    g=!randitem g,m,r
    #haakse lijnen
    rc1=$a/$b
    rc2=-1*$b/$a
    L1=($rc1)*x $pm $q
    L2=($rc2)*x $mp $p
    # x(rc1-rc2) = $mp $p - ($pm $q)
    #x=(($mp $p) - ($pm $q))/($rc1 - $rc2)
    
    TUSSEN=!exec pari printtex($L1)\
    printtex($L2)\
    (($mp $p) - ($pm $q))/(($rc1) - ($rc2))\
    a=(($mp $p) - ($pm $q))/(($rc1) - ($rc2)); ($rc1)*a $pm $q
    
    lijn1=!line 1 of $TUSSEN
    lijn2=!line 2 of $TUSSEN
    X=!line 3 of $TUSSEN
    Y=!line 4 of $TUSSEN

    GOED$n=$X,$Y
    !if $afrondingsfactor!=0
	x=$[(round($afrondingsfactor*$X))/$afrondingsfactor]
	y=$[(round($afrondingsfactor*$Y))/$afrondingsfactor]
    !else
	x=$X
	y=$Y
    !endif
        
    keuze=!randitem 1,2
    !if $keuze=1
    # lijn1>lijn2 ==> x>X
	gk= >
	ligging=$boven
	goed$n=x>$x
	ongelijkheid=x&gt;$x
    !else
    # lijn2>lijn1 = => x<X
	gk= <
	ligging=$onder
	goed$n=x<$x
	ongelijkheid=x&lt;$x
    !endif
    F=$f
    G=$g	
    f=&nbsp;<font size="+1"><em>$f</em></font>&nbsp;
    g=&nbsp;<font size="+1"><em>$g</em></font>&nbsp;
    opgave$n=$F(x) $gk $G(x)\rightarrow \left\{\begin{array}{c}$F(x)=$lijn1\\\\$G(x)=$lijn2\end{array}
    !if $taal=nl
	nivo_title=Bepaal de snijpunten tussen twee rechte lijnen<br>En los de ongelijkheid op. 
	somtekst$n=Gegeven zijn twee rechte lijnen $f en $g <br>\
		<ul><li>Bepaal de co&ouml;rdinaten van het snijpunt tussen $f en $g</li>\
		<li>Geef aan voor welke <em>x</em>-waarden de grafiek van $f $ligging die van $g ligt.</li>\
		<li>$AFRONDING</li></ul>
	antwoord$n=het snijpunt ($x:$y)<br> \
	De grafiek van $f ligt $ligging $g als geldt: $ongelijkheid
    !else
	nivo_title=Determine the intersection point of two lines<br>and solve the inequality.
	somtekst$n=Given the two lines $f and $g <br>\
		<ul><li>Determine the co&ouml;rdinates of the intersection of $f and $g</li>\
		<li>For which <em>x</em>-values is the line $f $ligging the line $g .</li>\
		<li>$AFRONDING</li></ul>
	antwoord$n=the intersection point ($x:$y)<br> \
	The graph of line $f is $ligging line $g when: $ongelijkheid
    !endif
    
    !if $PLAATJE=1
	transparent=$white
	GRAFIEK=linewidth 2\
	curve red,$L1\
	curve green,$L2\
	linewidth s*14\
	point $[$X],$[$Y],yellow
    !endif
 !goto KLAAR
!endif

!if $R>1
    a=!randitem 2,4,6,8,10
    b=!randitem 5,7,9,11,12,14,16,19
    q=!randitem 1,2,3,4,5,6,7,8,9
    p=!randitem 1,2,3,4,5,6,7,8,9
    c=!randitem 4,6,8,10
    s=$[$a+$c]
    !if $s=$q
	s=$[$q+2]
    !endif	
    pm=!randitem +,-
    mp=!randitem +,-
    #haakse lijnen
    rc1=$a/$b
    rc2=-1*$b/$a
    RR=($rc1)*x $pm $q
    G=($rc2)*x $mp $p
    B=($rc1)*x $pm $s
    r=&nbsp;<font size="+1"><em>r</em></font>&nbsp;
    g=&nbsp;<font size="+1"><em>g</em></font>&nbsp;
    b=&nbsp;<font size="+1"><em>b</em></font>&nbsp;
    # x(rc1-rc2) = $mp $p - ($pm $q)
    #x=(($mp $p) - ($pm $q))/($rc1 - $rc2)
    
    TUSSEN=!exec pari printtex($RR)\
    printtex($G)\
    printtex($B)\
    (($mp $p) - ($pm $q))/(($rc1) - ($rc2))\
    a=(($mp $p) - ($pm $q))/(($rc1) - ($rc2)); ($rc1)*a $pm $q\
    (($mp $p) - ($pm $s))/(($rc1) - ($rc2))\
    b=(($mp $p) - ($pm $s))/(($rc1) - ($rc2)); ($rc1)*b $pm $s
    
    R1=!line 1 of $TUSSEN
    G1=!line 2 of $TUSSEN
    B1=!line 3 of $TUSSEN
    X1=!line 4 of $TUSSEN
    Y1=!line 5 of $TUSSEN
    X2=!line 6 of $TUSSEN
    Y2=!line 7 of $TUSSEN

    !if $afrondingsfactor!=0
	x1=$[(round($afrondingsfactor*$X1))/$afrondingsfactor]
	x2=$[(round($afrondingsfactor*$X2))/$afrondingsfactor]
	y1=$[(round($afrondingsfactor*$Y1))/$afrondingsfactor]
	y2=$[(round($afrondingsfactor*$Y2))/$afrondingsfactor]
    !else
	x1=$X1
	x2=$X2
	y1=$Y1
	y2=$Y2
    !endif

    GOED$n=$X1,$Y1,$X2,$Y2
    
    !if $pm=+
	ligging=$g $boven $r $en $onder $b 
	goed$n=$x1<x&&x<$x2
	GG=$x1<x<$x2
	ongelijkheid=$x2 &lt; x &lt; $x1
	latextekst=r < g < b
    !else
	ligging=$g $onder $r $en $boven $b 
	goed$n=$x2<x&&x<$x1
	GG=$x2<x<$x1 
	ongelijkheid=$x1 &lt; x &lt; $x2
	latextekst=b < g < r
    !endif
    opgave$n=$latextekst\rightarrow \left\{\begin{array}{c}r(x)=$R1\\g(x)=$G1\\b(x)=$B1\end{array}
    !if $PLAATJE=1
	!if $taal=nl
	    extratekst=<p align="left">In de grafiek zijn de drie lijnen gekleurd weergegeven<br>\
	    de lijn $r is <font color=$fontcolor3> rood gekleurd</font> \
	    en de lijn $g is <font color=$fontcolor4> groen gekleurd</font><br>\
	    de lijn $b is natuurlijk <font color=$fontcolor6> in't blauw</font></p>
	!else
	    extratekst=<p align="left">In the graph the three lines are presented in colour.<br>\
	    The line $r is coloured <font color=$fontcolor3>red</font> \
	    , the line $g is drawn in <font color=$fontcolor4>green</font><br>\
	    and line $b is the <font color=$fontcolor6>blue</font> one</p>	
	!endif
    !endif
    !if $taal=nl
	nivo_title=Bepaal de snijpunten tussen drie rechte lijnen<br>En los de ongelijkheid op
	somtekst$n=Gegeven de drie rechte lijnen: $r  , $g en $b <br>\
	<ul>\
	<li>Bepaal de co&ouml;rdinaten van de snijpunten tussen $r , $g en $b</li>\
	<li>Geef aan voor welke <em>x</em>-waarden de grafiek van $ligging ligt .</li>\
	<li>$AFRONDING</li></ul><br>$extratekst
	antwoord$n=<div align="left">Het goede antwoord is dus: <ul><li>De snijpunten: ($x1:$y1) &and; ($x2:$y2)</li>\
	<li>En waar de grafiek van  $ligging  geldt: $ongelijkheid</li></ul></div>
    !else
	nivo_title=Determine the intersection points between three lines.<br>And solve the inquality
	somtekst$n=Give three lines : $r, $g and $b <br>\
	<ul>\
	<li>Determine the co&ouml;rdinates of the intersection points  of $r , $g and $b</li>\
	<li>For which <em>x</em>-values is the graph of $ligging  .</li>\
	<li>$AFRONDING</li></ul><br>$extratekst
	antwoord$n=<div align="left">The correct answer: <ul><li>The intersection points: ($x1:$y1) &and; ($x2:$y2)</li>\
	<li>And the graph of $ligging when: $ongelijkheid</li></ul></div>
    !endif
    !if $PLAATJE=1
	transparent=$white
	GRAFIEK=linewidth 2\
	curve red,$RR \
	curve green,$G \
	curve blue,$B \
	linewidth s*18\
	points yellow,$[$X1],$[$Y1],$[$X2],$[$Y2]
    !endif
!endif

:KLAAR

!if $PLAATJE=1
	XSIZE=240
        YSIZE=240
        XRANGE=-30,30
	YRANGE=-30,30
	XSCHAAL=5
	YSCHAAL=5

	!readproc $authordir/ruitjespapier.proc
	knipperen=1
        aantal_beeldjes=2

        plaatje$n=300,300\
	$ruitjespapier\
	transparent $transparent\
        xrange $XRANGE\
        yrange $YRANGE\
        linewidth 1\
        vline 0,0,blue\
        hline 0,0,blue\
	$GRAFIEK
!endif  
    

 
