/**
   * Vektor reflektion Vnew = - v + ( 2 * v * n) * n
   *
   * @param n Normale
   */
  public Vector3 reflectedOn(Normal3 n) {

    Vector3 resVector = this;

    double skalar = resVector.dot(n) * 2;

    Normal3 normale = n.mul(skalar);
    resVector = resVector.mul(-1.0);
    resVector = resVector.add(normale);

    return resVector;
  }
Example #2
0
 public Vector3 center(Vector3 optionalTarget) {
   return optionalTarget.add(this.min, this.max).multiply(0.5);
 }
Example #3
0
 public Matrix3 add(final Matrix3 m, final float i) {
   return new Matrix3(a.add(i, m.a), b.add(i, m.b), c.add(i, m.c));
 }
Example #4
0
 // Addition
 public Matrix3 add(final Matrix3 m) {
   return new Matrix3(a.add(m.a), b.add(m.b), c.add(m.c));
 }
Example #5
0
 /**
  * Returns the reflection of a vector u on a surface with normal n. Vector u points towards the
  * surface, vector r (result) points away from the surface. n is assumed to be normalized.
  *
  * @param u vector that will be reflected on the surface
  * @param n normal of the surface
  * @return reflected vector, facing away from the surface
  */
 public static Vector3 reflect(Vector3 u, Vector3 n) {
   double scalar = Vector3.dotProduct(u, n) * -2d;
   Vector3 result = Vector3.timesScalar(n, scalar);
   result = Vector3.add(result, u);
   return result;
 }