/** * Create a random point in ([0..1], [0..1], [0..1]). * * @return random point. */ public static Point3d createRandomPoint() { return new Point3dImpl(Math.random(), Math.random(), Math.random()); }
@Override public Point3dImpl copy() { return clone(); }
/** * Construct a Point3dImpl with the (x,y,z) coordinates given via another * point. * * @param p * The point to copy from. */ public Point3dImpl(Point3d p) { this.copyFrom(p); }
@Override public Point3dImpl transform(Matrix transform) { if (transform.getRowDimension() == 4) { double xt = transform.get(0, 0) * getX() + transform.get(0, 1) * getY() + transform.get(0, 2) * getZ() + transform.get(0, 3); double yt = transform.get(1, 0) * getX() + transform.get(1, 1) * getY() + transform.get(1, 2) * getZ() + transform.get(1, 3); double zt = transform.get(2, 0) * getX() + transform.get(2, 1) * getY() + transform.get(2, 2) * getZ() + transform.get(2, 3); final double ft = transform.get(3, 0) * getX() + transform.get(3, 1) * getY() + transform.get(3, 2) * getZ() + transform.get(3, 3); xt /= ft; yt /= ft; zt /= ft; return new Point3dImpl(xt, yt, zt); } throw new IllegalArgumentException("Transform matrix has unexpected size"); }
@Override public int hashCode() { return toString().hashCode(); }
@Override public boolean equals(Object o) { if (!(o instanceof Point3d)) return false; final Point3d p = (Point3d) o; return p.getX() == this.x && p.getY() == this.y && p.getZ() == this.getZ(); }
@Override public Point3d minus(Point3d a) { return new Point3dImpl(this.x - a.getX(), this.y - a.getY(), this.z - a.getZ()); }
ce.intrinsicParameters = intrinsic; ce.rotation = R; ce.translation = new Point3dImpl(t.getColumnPackedCopy());