ing getView () {(a <0? - a: a) + В«* x1 +В» + (b <0? - b: b) + В«* x2 <=В» + c;
}
}
Клас В«PolygonВ»
class Polygon {ArrayList points = new ArrayList (); ArrayList infinity = new ArrayList (); ArrayList values ​​= new ArrayList ();
Rect viewBox;
Rect getViewBox () {viewBox;
}
ArrayList getPoints () {points;
}
Point getPoint (int i) {points.get (i);
}
boolean getInfinity (int i) {infinity.get (i);
}
float getValue (int i) {values.get (i);
}
void clear () {. clear ();. clear ();. clear (); = null;
}
void addPoint (Point p, boolean inf) {. add (p);. add (0.0f);. add (inf);
}
Polygon () {
}
Polygon (BoundingBox bb, boolean b) {h = bb.getHigh (); l = bb.getLow ();
(new Point (h), b); (new Point (lx, hy), b); (new Point (l), b); (new Point (hx, ly), b );
}
Polygon (ArrayList lines) {
// this.lines = lines;
bb = new BoundingBox (); (Line li: lines) {(Line lj: lines) {p = li.getIntersection (lj);
if (p == null);
PointIn = true; (Line l: lines) {(l! = li && l! = lj && l.getDistanceToPoint (p) <0) {= false; ;
}
}
(PointIn) {. addPoint (p);
}
}
}
(! bb.isEmpty ()) {. extend (1.0f); = new Rect (bb);
}
(new Polygon (bb, true), lines);
}
void cutPolygonWithLines (Polygon p, ArrayList lines) {= p.points; = p.infinity; = p.values;
for (Line l: lines) {(l);
}
}
List getBoundingPoints (Rect viewRec) {points;
}
void cutWithLine (Line l) {p = new Polygon (); crossingPt = null; (int i = 0; i
orgIsInside = (l.getDistanceToPoint (points.get (i))> 0); destIsInside = (l.getDistanceToPoint (points.get (next))> 0); infEdge = infinity. get (i);
(orgIsInside! = destIsInside) {= l.getIntersection (new Line (points.get (i), points.get (next)));