Пример #1
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 Vector2f fma(Vector2f a, Vector2f b, Vector2f dest) {
   dest.x = x + a.x * b.x;
   dest.y = y + a.y * b.y;
   return dest;
 }
Пример #2
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 Vector2f fma(float a, Vector2f b, Vector2f dest) {
   dest.x = x + a * b.x;
   dest.y = y + a * b.y;
   return dest;
 }
Пример #3
0
 /**
  * Multiply the components of this vector by the given scalar and store the result in <code>dest
  * </code>.
  *
  * @param scalar the value to multiply this vector's components by
  * @param dest will hold the result
  * @return dest
  */
 public Vector2f mul(float scalar, Vector2f dest) {
   dest.x *= scalar;
   dest.y *= scalar;
   return dest;
 }
Пример #4
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 Vector2f lerp(Vector2f other, float t, Vector2f dest) {
   dest.x = x + (other.x - x) * t;
   dest.y = y + (other.y - y) * t;
   return dest;
 }
Пример #5
0
 /**
  * Negate this vector and store the result in <code>dest</code>.
  *
  * @param dest will hold the result
  * @return dest
  */
 public Vector2f negate(Vector2f dest) {
   dest.x = -x;
   dest.y = -y;
   return dest;
 }
Пример #6
0
 /**
  * Add <code>a</code> to <code>b</code> and store the result in <code>dest</code>.
  *
  * @param a the first addend
  * @param b the second addend
  * @param dest will hold the result
  */
 public static void add(Vector2f a, Vector2f b, Vector2f dest) {
   dest.x = a.x + b.x;
   dest.y = a.y + b.y;
 }
Пример #7
0
 /**
  * Normalize this vector and store the result in <code>dest</code>.
  *
  * @param dest will hold the result
  * @return dest
  */
 public Vector2f normalize(Vector2f dest) {
   float invLength = (float) (1.0 / Math.sqrt(x * x + y * y));
   dest.x = x * invLength;
   dest.y = y * invLength;
   return dest;
 }
Пример #8
0
 /**
  * Subtract <code>b</code> from <code>a</code> and store the result in <code>dest</code>.
  *
  * @param a the first operand
  * @param b the second operand
  * @param dest will hold the result of <code>a - b</code>
  */
 public static void sub(Vector2f a, Vector2f b, Vector2f dest) {
   dest.x = a.x - b.x;
   dest.y = a.y - b.y;
 }
Пример #9
0
 /**
  * Store one perpendicular vector of <code>v</code> in <code>dest</code>.
  *
  * @param v the vector to build one perpendicular vector of
  * @param dest will hold the result
  */
 public static void perpendicular(Vector2f v, Vector2f dest) {
   dest.x = v.y;
   dest.y = v.x * -1;
 }