Ejemplo n.º 1
0
 /**
  * Multiply this Vector4d by the given scalar value and store the result in <code>dest</code>.
  *
  * @param scalar the factor to multiply by
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d mul(double scalar, Vector4d dest) {
   dest.x = x * scalar;
   dest.y = y * scalar;
   dest.z = z * scalar;
   dest.w = w * scalar;
   return dest;
 }
Ejemplo n.º 2
0
 /**
  * Divide this Vector4d by the given scalar value and store the result in <code>dest</code>.
  *
  * @param scalar the factor to divide by
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d div(double scalar, Vector4d dest) {
   dest.x = x / scalar;
   dest.y = y / scalar;
   dest.z = z / scalar;
   dest.w = w / scalar;
   return dest;
 }
Ejemplo n.º 3
0
 /**
  * Multiply this {@link Vector4d} component-wise by the given {@link Vector4d} and store the
  * result in <code>dest</code>.
  *
  * @param v the vector to multiply this by
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d mul(Vector4d v, Vector4d dest) {
   dest.x = x * v.x;
   dest.y = y * v.y;
   dest.z = z * v.z;
   dest.w = w * v.w;
   return dest;
 }
Ejemplo n.º 4
0
 /**
  * Divide this {@link Vector4d} component-wise by the given {@link Vector4d} and store the result
  * in <code>dest</code>.
  *
  * @param v the vector to divide this by
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d div(Vector4d v, Vector4d dest) {
   dest.x = x / v.x;
   dest.y = y / v.y;
   dest.z = z / v.z;
   dest.w = w / v.w;
   return dest;
 }
Ejemplo n.º 5
0
 /**
  * Add the component-wise multiplication of <code>a * b</code> to this vector and store the result
  * in <code>dest</code>.
  *
  * @param a the first multiplicand
  * @param b the second multiplicand
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d fma(Vector4d a, Vector4d b, Vector4d dest) {
   dest.x = x + a.x * b.x;
   dest.y = y + a.y * b.y;
   dest.z = z + a.z * b.z;
   dest.w = w + a.w * b.w;
   return dest;
 }
Ejemplo n.º 6
0
 /**
  * Add the component-wise multiplication of <code>a * b</code> to this vector and store the result
  * in <code>dest</code>.
  *
  * @param a the first multiplicand
  * @param b the second multiplicand
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d fma(double a, Vector4d b, Vector4d dest) {
   dest.x = x + a * b.x;
   dest.y = y + a * b.y;
   dest.z = z + a * b.z;
   dest.w = w + a * b.w;
   return dest;
 }
Ejemplo n.º 7
0
 /**
  * Add <tt>(x, y, z, w)</tt> to this and store the result in <code>dest</code>.
  *
  * @param x the x component to subtract
  * @param y the y component to subtract
  * @param z the z component to subtract
  * @param w the w component to subtract
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d add(double x, double y, double z, double w, Vector4d dest) {
   dest.x = this.x - x;
   dest.y = this.y - y;
   dest.z = this.z - z;
   dest.w = this.w - w;
   return dest;
 }
Ejemplo n.º 8
0
 /**
  * Linearly interpolate <code>this</code> and <code>other</code> using the given interpolation
  * factor <code>t</code> and store the result in <code>dest</code>.
  *
  * <p>If <code>t</code> is <tt>0.0</tt> then the result is <code>this</code>. If the interpolation
  * factor is <code>1.0</code> then the result is <code>other</code>.
  *
  * @param other the other vector
  * @param t the interpolation factor between 0.0 and 1.0
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d lerp(Vector4d other, double t, Vector4d dest) {
   dest.x = x + (other.x - x) * t;
   dest.y = y + (other.y - y) * t;
   dest.z = z + (other.z - z) * t;
   dest.w = w + (other.w - w) * t;
   return dest;
 }
Ejemplo n.º 9
0
 /**
  * Compute a hermite interpolation between <code>this</code> vector and its associated tangent
  * <code>t0</code> and the given vector <code>v</code> with its tangent <code>t1</code> and store
  * the result in <code>dest</code>.
  *
  * @param t0 the tangent of <code>this</code> vector
  * @param v1 the other vector
  * @param t1 the tangent of the other vector
  * @param t the interpolation factor, within <tt>[0..1]</tt>
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d hermite(Vector4d t0, Vector4d v1, Vector4d t1, double t, Vector4d dest) {
   double t2 = t * t;
   double t3 = t2 * t;
   dest.x =
       (x + x - v1.x - v1.x + t1.x + t0.x) * t3
           + (3.0 * v1.x - 3.0 * x - t0.x - t0.x - t1.x) * t2
           + x * t
           + x;
   dest.y =
       (y + y - v1.y - v1.y + t1.y + t0.y) * t3
           + (3.0 * v1.y - 3.0 * y - t0.y - t0.y - t1.y) * t2
           + y * t
           + y;
   dest.z =
       (z + z - v1.z - v1.z + t1.z + t0.z) * t3
           + (3.0 * v1.z - 3.0 * z - t0.z - t0.z - t1.z) * t2
           + z * t
           + z;
   dest.w =
       (w + w - v1.w - v1.w + t1.w + t0.w) * t3
           + (3.0 * v1.w - 3.0 * w - t0.w - t0.w - t1.w) * t2
           + w * t
           + w;
   return dest;
 }
Ejemplo n.º 10
0
 /**
  * Negate this vector and store the result in <code>dest</code>.
  *
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d negate(Vector4d dest) {
   dest.x = -x;
   dest.y = -y;
   dest.z = -z;
   dest.w = -w;
   return dest;
 }
Ejemplo n.º 11
0
 /**
  * Normalize this vector by computing only the norm of <tt>(x, y, z)</tt> and store the result in
  * <code>dest</code>.
  *
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d normalize3(Vector4d dest) {
   double invLength = 1.0 / Math.sqrt(x * x + y * y + z * z);
   dest.x = x * invLength;
   dest.y = y * invLength;
   dest.z = z * invLength;
   dest.w = w * invLength;
   return dest;
 }
Ejemplo n.º 12
0
 /**
  * Normalizes this vector and store the result in <code>dest</code>.
  *
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d normalize(Vector4d dest) {
   double invLength = 1.0 / length();
   dest.x = x * invLength;
   dest.y = y * invLength;
   dest.z = z * invLength;
   dest.w = w * invLength;
   return dest;
 }
Ejemplo n.º 13
0
 /**
  * Compute a smooth-step (i.e. hermite with zero tangents) interpolation between <code>this</code>
  * vector and the given vector <code>v</code> and store the result in <code>dest</code>.
  *
  * @param v the other vector
  * @param t the interpolation factor, within <tt>[0..1]</tt>
  * @param dest will hold the result
  * @return dest
  */
 public Vector4d smoothStep(Vector4d v, double t, Vector4d dest) {
   double t2 = t * t;
   double t3 = t2 * t;
   dest.x = (x + x - v.x - v.x) * t3 + (3.0 * v.x - 3.0 * x) * t2 + x * t + x;
   dest.y = (y + y - v.y - v.y) * t3 + (3.0 * v.y - 3.0 * y) * t2 + y * t + y;
   dest.z = (z + z - v.z - v.z) * t3 + (3.0 * v.z - 3.0 * z) * t2 + z * t + z;
   dest.w = (w + w - v.w - v.w) * t3 + (3.0 * v.w - 3.0 * w) * t2 + w * t + w;
   return dest;
 }
Ejemplo n.º 14
0
 /**
  * Add <code>v2</code> to <code>v1</code> and store the result in <code>dest</code>.
  *
  * @param v1 the first addend
  * @param v2 the second addend
  * @param dest will hold the result
  */
 public static void add(Vector4f v1, Vector4d v2, Vector4d dest) {
   dest.x = v1.x + v2.x;
   dest.y = v1.y + v2.y;
   dest.z = v1.z + v2.z;
   dest.w = v1.w + v2.w;
 }
Ejemplo n.º 15
0
 /**
  * Subtract <code>v2</code> from <code>v1</code> and store the result in <code>dest</code>.
  *
  * @param v1 the left operand
  * @param v2 the right operand
  * @param dest will hold the result
  */
 public static void sub(Vector4f v1, Vector4d v2, Vector4d dest) {
   dest.x = v1.x - v2.x;
   dest.y = v1.y - v2.y;
   dest.z = v1.z - v2.z;
   dest.w = v1.w - v2.w;
 }