class TLine { var a, b, c, abroot, k:Number; function TLine(mya:Number, myb:Number, myc:Number) { a = mya; b = myb; c = myc; abroot = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)); if (b != 0) { k = -(a/b); } else { k = Infinity; } } public function reset(mya:Number, myb:Number, myc:Number) { a = mya; b = myb; c = myc; abroot = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)); if (b != 0) { k = -(a/b); } else { k = Infinity; } } public function paraTo(other:TLine) { if ((other.a*b-other.b*a == 0) && ((other.a*this.c-other.c*this.a != 0) || (other.b*this.c-other.c*this.b != 0))) { return true; } else { return (false); } } public function vertTo(other:TLine) { trace(other.a*a+other.b*b); if (other.a*a+other.b*b == 0) { return true; } else { return false; } } public function distTo(other:TLine) { var lemt:Number; if (paraTo(other)) { if (other.a != 0) { lemt = a/other.a; } else { lemt = b/other.b; } return ((other.c*lemt-c)/abroot); } else { return (false); } } public function insectPoint(other:TLine) { var lemt:Number; if (!paraTo(other)) { if (other.a != 0) { lemt = -a/other.a; var y1:Number = (-c-other.c*lemt)/(b+other.b*lemt); var x1:Number = (-other.c-other.b*y1)/other.a; } else { lemt = -b/other.b; var x1:Number = (-c-other.c*lemt)/(a+other.a*lemt); var y1:Number = (-other.c-other.a*x1)/other.b; } var p1:TPoint = new TPoint(x1, y1); return p1; } } public function calcX(y1:Number) { if (a != 0) { return ((-c-b*y1)/a); } else { return false; } } public function calcY(x1:Number) { if (b != 0) { return ((-c-a*x1)/b); } else { return false; } } public function outform() { var a1:String = String(a); var b1:String = String(b); var c1:String = String(c); if (a == 0) { a1 = ""; } else { if (a == 1) { a1 = "x"; } else if (a == -1) { a1 = "-x"; } else { a1 += "x"; } } if (b == 0) { b1 = ""; } else if (b>0) { if (b == 1) { b1 = "+y"; } else { b1 = "+"+b1+"y"; } } else { if (b == -1) { b1 = "-y"; } else { b1 += "y"; } } if (c == 0) { c1 = ""; } else if (c>0) { c1 = "+"+c1; } return (a1+b1+c1+"=0"); } public function posiFini() { if (b != 0) { var p1:TPoint = new TPoint(100, calcY(100)); return p1; } var p1:TPoint = new TPoint(calcX(100), 100); return p1; } public function negaFini() { if (b != 0) { var p1:TPoint = new TPoint(-100, calcY(-100)); return p1; } var p1:TPoint = new TPoint(calcX(-100), -100); return p1; } public function getValue(x:Number,y:Number){ return(a*x+b*y+c); } }