<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>Systemes d'inequations</TITLE>
<script>
<![CDATA[
var xmin=-10,xmax=10,ymin=-10,ymax=10;
var x = new Array,y= new Array;
var a = new Array, b = new Array , c = new Array , d = new Array;

function cadre(u,v,w,s)
{
	nbpoints=0
	poly="";
	if ((u==0)&&(v==0)) 
		nbpoints=3
	if (((u==1)&&(v==1)&&(w==0))||((u==-1)&&(v==-1)&&(w==0))) 
	{
		y[1]=ymin
		y[2]=ymax
		x[1]=xmax
		x[2]=xmin
		nbpoints=2
		if (((s==0)&&(u==1))||((s==1)&&(u==-1)))
			poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		else
			poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		return
	}
	if (((u==1)&&(v==-1)&&(w==0))||((u==-1)&&(v==1)&&(w==0))) 
	{
		y[1]=ymax
		y[2]=ymin
		x[1]=xmax
		x[2]=xmin
		nbpoints=2
		if (((s==0)&&(u==1))||((s==1)&&(u==-1)))
			poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		else
			poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		return
	}
	if ((u==0)&&(v!=0)) 
	{
		if ((-w/v<ymax)&&(-w/v>ymin)) 
		{
			y[1]=-w/v
			y[2]=-w/v
			x[1]=xmin
			x[2]=xmax
			nbpoints=2
			if (((s==0)&&(10*v+w>0))||((s==1)&&(10*v+w<0)))
				poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 0 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
					else
				poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 400 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		}
		return
	}
	if ((v==0)&&(u!=0))
	{
		if ((-w/u<xmax)&&(-w/u>xmin)) 
		{
			x[1]=-w/u
			x[2]=-w/u
			y[1]=ymin
			y[2]=ymax
			nbpoints=2
			if (((s==0)&&(10*u+w>0))||((s==1)&&(10*u+w<0)))
				poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 400 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
					else
				poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 0 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		}
		return
	}
	if ((u!=0)&&(v!=0)&&(nbpoints<2))
	{
		y0=(-u*xmin-w)/v;
		if ((y0>ymin)&&(y0<ymax)) 
		{
			nbpoints+=1
			x[nbpoints]=xmin
			y[nbpoints]=y0
			poly="G"
		};
		y0=(-u*xmax-w)/v;
		if ((y0>ymin)&&(y0<ymax)) 
		{
			nbpoints+=1
			x[nbpoints]=xmax
			y[nbpoints]=y0
			if (nbpoints==2)
			{
				if (((s==0)&&(10*u+10*v+w>0))||((s==1)&&(10*u+10*v+w<0)))
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 0 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
						else
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 400 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
			} 
			else 
				poly="D"
		}
		x0=(-v*ymin-w)/u;
		if ((x0>xmin)&&(x0<xmax)&&(nbpoints<2)) 
		{
			nbpoints+=1
			x[nbpoints]=x0
			y[nbpoints]=ymin;
			if (nbpoints==2)
			{
				if (poly=="G")
					if (((s==0)&&(10*u+10*v+w>0))||((s==1)&&(10*u+10*v+w<0)))
						poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 0 400 0 400 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
							else
						poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
				if (poly=="D")
					if (((s==0)&&(10*u+10*v+w>0))||((s==1)&&(10*u+10*v+w<0)))
						poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 0 0 0 0 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
							else
						poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 400 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
			}
			else 
				poly="B"
		};
		x0=(-v*ymax-w)/u;
		if ((x0>xmin)&&(x0<xmax)&&(nbpoints<2)) 
		{
			nbpoints+=1
			x[nbpoints]=x0
			y[nbpoints]=ymax
		}
		if (nbpoints==2)
		{
			if (poly=="G")
				if (((s==0)&&(10*u+10*v+w>0))||((s==1)&&(10*u+10*v+w<0)))
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 400 400 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
						else
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
			if (poly=="D")
				if (((s==0)&&(10*u+10*v+w<0))||((s==1)&&(10*u+10*v+w>0)))
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 400 0 400 0 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
						else
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
			if (poly=="B")
				if (((s==0)&&(10*u+10*v+w>0))||((s==1)&&(10*u+10*v+w<0)))
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 400 400 400 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
						else
					poly="M "+Math.round(200+20*x[1])+" "+Math.round(200-20*y[1])+" 0 400 0 0 "+Math.round(200+20*x[2])+" "+Math.round(200-20*y[2])+" z"
		}
	}
}

function Coeffs()
{
	var u1 = parseFloat(document.getElementById("u1").value)
	var v1 = parseFloat(document.getElementById("v1").value)
	var w1 = parseFloat(document.getElementById("w1").value)
	var s1 = document.getElementById("D1").selectedIndex
	cadre(u1,v1,w1,s1);
	if (nbpoints == 3) 
		alert("Line D1 do not exist ....");
	if (nbpoints < 2) 
		alert("Line D1 is out of canvas");
	if (nbpoints == 2) 
		document.getElementById("curve1").setAttribute("d",poly)
	var u2 = parseFloat(document.getElementById("u2").value)
	var v2 = parseFloat(document.getElementById("v2").value)
	var w2 = parseFloat(document.getElementById("w2").value)
	var s2 = document.getElementById("D2").selectedIndex
	cadre(u2,v2,w2,s2);
	if (nbpoints == 3) 
		alert("Line D2 do not exist ....");
	if (nbpoints < 2) 
		alert("Line D2 is out of canvas");
	if (nbpoints == 2) 
		document.getElementById("curve2").setAttribute("d",poly)
	var u3 = parseFloat(document.getElementById("u3").value)
	var v3 = parseFloat(document.getElementById("v3").value)
	var w3 = parseFloat(document.getElementById("w3").value)
	var s3 = document.getElementById("D3").selectedIndex
	cadre(u3,v3,w3,s3);
	if (nbpoints == 3) 
		alert("Line D3 do not exist ....");
	if (nbpoints < 2) 
		alert("Line D3 is out of canvas");
	if (nbpoints == 2) 
		document.getElementById("curve3").setAttribute("d",poly)
}
]]>
</script>
</head>
<body bgColor="#A7EDDF" onload="Coeffs()">
<font face="Verdana" size="2">
<p align="center"><b>Solve systems of linears inequations</b></p>
<table border="0" width="100%" style="text-align: center">
<tr>
<td width="50%">
<svg xmlns="http://www.w3.org/2000/svg" id="root" xml:space="preserve" width="400" height="400" >
 	<rect id="bkgrnd" x="0" y="0" width="400" height="400" style="fill:#FFFFFF"/> 
	<path id="repere3" style="stroke-width:1; stroke:cyan; fill:none" d="M0 20 h400 M0 40 h400 M0 60 h400 M0 80 h400 M0 100 h400 M0 120 h400 M0 140 h400 M0 160 h400 M0 180 h400 M0 220 h400 M0 240 h400 M0 260 h400 M0 280 h400 M0 300 h400 M0 320 h400 M0 340 h400 M0 360 h400 M0 380 h400"/>
	<path id="repere4" style="stroke-width:1; stroke:cyan; fill:none" d="M20 0 v400 M40 0 v400 M60 0 v400 M80 0 v400 M100 0 v400 M120 0 v400 M140 0 v400 M160 0 v400 M180 0 v400 M220 0 v400 M240 0 v400 M260 0 v400 M280 0 v400 M300 0 v400 M320 0 v400 M340 0 v400 M360 0 v400 M380 0 v400"/>
	<path id="repere" style="stroke-width:1; stroke:black; fill:none" d="M0 200 h400 M200 0 v400"/>
	<path id="repere2" style="stroke-width:1; stroke:green; fill:none" d="M195 185 L200 180 L205 185 M215 195 L220 200 L215 205"/>
	<path id="curve1" style="stroke-width:1; stroke:blue; fill:blue;fill-opacity:0.3" d="M0 0"/>
	<path id="curve2" style="stroke-width:1; stroke:red; fill:red;fill-opacity:0.3" d="M0 0"/>
	<path id="curve3" style="stroke-width:1; stroke:green; fill:green;fill-opacity:0.3" d="M0 0"/> 
</svg>
</td>
<td width="50%">
<p>
You can change values for lines
</p>
<p>
You can change inequation also
</p>
<p>
<form name="entre" align="center">
<p>
<input id="u1" size="2" value="-1" type="text"/>   x + 
<input id="v1" size="2" value="-2" type="text"/> y + 
<input id="w1" size="2" value="3"/>
<select size="1" id="D1">
  <option value="sup">&gt;</option>
  <option value="inf"> &lt; </option>
</select> 0
</p>
<p>
<input id="u2" size="2" value="-1" type="text"/>   x + 
<input id="v2" size="2" value="2" type="text"/> y + 
<input id="w2" size="2" value="4"/>
<select size="1" id="D2">
  <option value="sup">&gt;</option>
  <option value="inf"> &lt; </option>
</select> 0
</p>
<p>
<input id="u3" size="2" value="4" type="text"/>   x + 
<input id="v3" size="2" value="0.5" type="text"/> y + 
<input id="w3" size="2" value="6"/>
<select size="1" id="D3">
  <option value="sup">&gt;</option>
  <option value="inf"> &lt; </option>
</select> 0 
</p>
<p>
<input onclick="Coeffs()" type="button" value="Solve"/> 
</p>
 </form>
 </p>
 <p>
 </p>
 <p>
 Click on button Solve to see solution
 </p>
 <p>
 Solution is area in dark color
 </p>
 <p>
 part of red, green and blue areas
 </p>
</td>
</tr>
</table>
</font>
</body>
</html>
