public void move(double dx, double dy) { int n = countPoint(); for (int i = 0; i < n; i++) { PointCoord p = (PointCoord)this.polygon[i]; p.x += dx; p.y += dy; } }
public PointCoord pointMirrorSymmetry(PointCoord p) { if (this.isVertical()) { return(new PointCoord(2 * a - p.x, p.y)); } else { double x2 = (2 * (p.y - b) + (1 / k - k) * p.x) / (k + 1 / k); double y2 = p.y + (p.x - x2) / k; return(new PointCoord(x2, y2)); } }
public Polygon toScrPolygon(int x0, int y0) { if (type == TYPE_POLYGON) { int n = countPoint(); int[] x = new int[n], y = new int[n]; for (int i = 0; i < n; i++) { Point p = PointCoord.toScrPoint(getPoint(i).x, getPoint(i).y, x0, y0); x[i] = p.X; y[i] = p.Y; } return(new Polygon(x, y, n)); } else { return(null); //????? } }
public PicObject picObjectMirrorSymmetry(PicObject pic) { if (pic.mirror == this) { return(null); // a Pic In this mirror can not through the mirror itself } Color color = colorMirrorRef(pic.color, refl); PicObject pic2 = new PicObject(pic.type, color, pic.filled); int n = pic.countPoint(); for (int i = 0; i < n; i++) { PointCoord p = pic.getPoint(i); pic2.addPoint(pointMirrorSymmetry(p)); } pic2.mirror = this; pic2.originalPicObject = pic.originalPicObject; pic2.srcPicObject = pic; return(pic2); }
public bool contains(PointCoord p) { return(toScrPolygon(0, 0).contains(p.toScrPoint(0, 0))); }
public void addPoint(PointCoord p) { addPoint(p.x, p.y); }