Exemplo n.º 1
0
  public Vector3d reflect(Vector3d point, Vector3d store) {
    if (store == null) store = new Vector3d();

    double d = pseudoDistance(point);
    store.set(normal).negateLocal().multLocal(d * 2f);
    store.addLocal(point);
    return store;
  }
Exemplo n.º 2
0
 @Override
 public PlaneD clone() {
   try {
     PlaneD p = (PlaneD) super.clone();
     p.normal = normal.clone();
     return p;
   } catch (CloneNotSupportedException e) {
     throw new AssertionError();
   }
 }
Exemplo n.º 3
0
 /**
  * Initialize the PlaneD using the given 3 points as coplanar.
  *
  * @param v1 the first point
  * @param v2 the second point
  * @param v3 the third point
  */
 public void setPlanePoints(Vector3d v1, Vector3d v2, Vector3d v3) {
   normal.set(v2).subtractLocal(v1);
   normal.crossLocal(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z).normalizeLocal();
   constant = normal.dot(v1);
 }
Exemplo n.º 4
0
 /**
  * <code>pseudoDistance</code> calculates the distance from this PlaneD to a provided point. If
  * the point is on the negative side of the PlaneD the distance returned is negative, otherwise it
  * is positive. If the point is on the PlaneD, it is zero.
  *
  * @param point the point to check.
  * @return the signed distance from the PlaneD to a point.
  */
 public double pseudoDistance(Vector3d point) {
   return normal.dot(point) - constant;
 }
Exemplo n.º 5
0
 public Vector3d getClosestPoint(Vector3d point, Vector3d store) {
   //        double t = constant - normal.dot(point);
   //        return store.set(normal).multLocal(t).addLocal(point);
   double t = (constant - normal.dot(point)) / normal.dot(normal);
   return store.set(normal).multLocal(t).addLocal(point);
 }