/** * @return Maximum coordinate of bounding box */ public Point getMinPoint() { return new Point(minX, minY, minZ); }
/** * @return Minimum coordinate of bounding box */ public Point getMaxPoint() { return new Point(maxX, maxY, maxZ); } }
public static Point toJdtPoint(Coord3d coord) { return new Point(coord.x, coord.y, coord.z); }
public static Point toJdtPoint(double x, double y, double z) { return new Point(x, y, z); }
Point circumcenter(Point a, Point b) { double u = ((a.x - b.x) * (a.x + b.x) + (a.y - b.y) * (a.y + b.y)) / 2.0f; double v = ((b.x - x) * (b.x + x) + (b.y - y) * (b.y + y)) / 2.0f; double den = (a.x - b.x) * (b.y - y) - (b.x - x) * (a.y - b.y); if (den == 0) // oops System.out.println("circumcenter, degenerate case"); return new Point((u * (b.y - y) - v * (a.y - b.y)) / den, (v * (a.x - b.x) - u * (b.x - x)) / den); }
private static List<Point> readTsin(BufferedReader is, String firstLine) throws IOException { List<Point> points = new ArrayList<Point>(); String s; while ((s = is.readLine()) != null) { StringTokenizer st = new StringTokenizer(s); double d1 = new Double(st.nextToken()).doubleValue(); double d2 = new Double(st.nextToken()).doubleValue(); double d3 = new Double(st.nextToken()).doubleValue(); points.add(new Point(d1, d2, d3)); } return points; }
/** * * @param x * - X cordination of the query point * @param y * - Y cordination of the query point * @return true iff (x,y) falls inside this triangulation (in its 2D convex * hull). */ public boolean contains(double x, double y) { return contains(new Point(x, y)); }
/** * compute the Z value for the X,Y values of q. assume this triangle * represent a plane --> q does NOT need to be contained in this triangle. * * @param x * x-coordinate of the query point. * @param y * y-coordinate of the query point. * @return z (height) value approximation given by the triangle it falls in. * */ public double getZ(double x, double y) { return zValue(new Point(x, y)); }
private static List<Point> readSmf(BufferedReader is) throws IOException { String s; while (!(s = is.readLine()).startsWith("v")) { } double dx = 1, dy = 1, dz = 1, minX = 0, minY = 0, minZ = 0; List<Point> points = new ArrayList<Point>(); while (s != null && s.charAt(0) == 'v') { StringTokenizer st = new StringTokenizer(s); st.nextToken(); double d1 = new Double(st.nextToken()).doubleValue() * dx + minX; double d2 = new Double(st.nextToken()).doubleValue() * dy + minY; double d3 = new Double(st.nextToken()).doubleValue() * dz + minZ; points.add(new Point(d1, d2, d3)); s = is.readLine(); } return points; }
/** * * @param x * - X cordination of the query point * @param y * - Y cordination of the query point * @return the q point with updated Z value (z value is as given the * triangulation). */ public double z(double x, double y) { Point q = new Point(x, y); Triangle t = find(q); return t.zValue(q); }
/** * Create a point at the center of a cell * * @param xIndex * horizontal cell index * @param yIndex * vertical cell index * @return Point at the center of the cell at (xIndex, yIndex) */ private Point middleOfCell(int xIndex, int yIndex) { double middleXCell = indexRegion.minX() + xIndex * xSize + xSize / 2; double middleYCell = indexRegion.minY() + yIndex * ySize + ySize / 2; return new Point(middleXCell, middleYCell); } }
/** * @return The bounding rectange between the minimum and maximum coordinates * of the triangle */ public BoundingBox getBoundingBox() { Point lowerLeft, upperRight; lowerLeft = new Point(Math.min(a.getX(), Math.min(b.getX(), c.getX())), Math.min(a.getY(), Math.min(b.getY(), c.getY()))); upperRight = new Point(Math.max(a.getX(), Math.max(b.getX(), c.getX())), Math.max(a.getY(), Math.max(b.getY(), c.getY()))); return new BoundingBox(lowerLeft, upperRight); }
/** * compute the Z value for the X,Y values of q. assume this triangle * represent a plane --> q does NOT need to be contained in this triangle. * * @param q * query point (its Z value is ignored). * @return q with updated Z value. * */ public Point getZ(Point q) { double z = zValue(q); return new Point(q.getX(), q.getY(), z); }
private void updateBoundingBox(Point p) { double x = p.getX(), y = p.getY(), z = p.getZ(); if (bbMin == null) { bbMin = new Point(p); bbMax = new Point(p); } else { if (x < bbMin.getX()) bbMin.setX(x); else if (x > bbMax.getX()) bbMax.setX(x); if (y < bbMin.getY()) bbMin.setY(y); else if (y > bbMax.getY()) bbMax.setY(y); if (z < bbMin.getZ()) bbMin.setZ(z); else if (z > bbMax.getZ()) bbMax.setZ(z); } }
result[1] = new Point(xCellLine, yCellLine);
Circle circumcircle() { double u = ((a.getX() - b.getX()) * (a.getX() + b.getX()) + (a.getY() - b.getY()) * (a.getY() + b.getY())) / 2.0f; double v = ((b.getX() - c.getX()) * (b.getX() + c.getX()) + (b.getY() - c.getY()) * (b.getY() + c.getY())) / 2.0f; double den = (a.getX() - b.getX()) * (b.getY() - c.getY()) - (b.getX() - c.getX()) * (a.getY() - b.getY()); if (den == 0) // oops, degenerate case circum = new Circle(a, Double.POSITIVE_INFINITY); else { Point cen = new Point((u * (b.getY() - c.getY()) - v * (a.getY() - b.getY())) / den, (v * (a.getX() - b.getX()) - u * (b.getX() - c.getX())) / den); circum = new Circle(cen, cen.distance2(a)); } return circum; }