示例#1
0
 @Override
 public boolean equals(Object obj) {
   if (obj == null) return false;
   if (obj instanceof Vector) {
     Vector vec = (Vector) obj;
     return this.x() == vec.x() && this.y() == vec.y() && this.z() == vec.z();
   } else {
     return false;
   }
 }
示例#2
0
 /**
  * Returns the euler angles from position 1 to position 2.
  *
  * <p>The returned vector has Y for yaw, and X for pitch. Measurements are in radians.
  *
  * @param pos1 Where we are
  * @param pos2 Where to look at
  */
 public static Vector getRotations(Vector pos1, Vector pos2) {
   Vector diff = pos2.minus(pos1);
   diff.normalize();
   double x = diff.x();
   double y = diff.y();
   double z = diff.z();
   double d0 = x;
   double d1 = y;
   double d2 = z;
   double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);
   double rotY = Math.atan2(d2, d0) - Math.PI / 2;
   double rotX = -Math.atan2(d1, d3);
   double rotZ = 0;
   return new Vector(rotX, rotY, rotZ);
 }
示例#3
0
 /** Create a unit vector from the given euler angles. Measurements should be in radians. */
 public static Vector fromDirection(Vector euler) {
   return fromYawPitch(euler.y(), euler.x());
 }
示例#4
0
 /**
  * Returns the cross product of the given vector. This creates a new vector.
  *
  * @param vec The vector to cross with
  */
 public Vector cross(Vector vec) {
   return cross(vec.x(), vec.y(), vec.z());
 }
示例#5
0
 /**
  * Get the square distance from the given vector.
  *
  * @param vec The other vector
  */
 public double sqrDist(Vector vec) {
   return sqrDist(vec.x(), vec.y(), vec.z());
 }
示例#6
0
 /**
  * Get the dot product with the given vector.
  *
  * @param vec The other vector
  */
 public double dot(Vector vec) {
   return dot(vec.x(), vec.y(), vec.z());
 }
示例#7
0
 /**
  * Creates a new vector from this vector minus the given vector.
  *
  * @param vec Other vector
  */
 public Vector minus(Vector vec) {
   return minus(vec.x(), vec.y(), vec.z());
 }
示例#8
0
 /**
  * Subtract the given vector from this vector.
  *
  * @param vec The reduction vector
  * @return this
  */
 public Vector subtract(Vector vec) {
   return subtract(vec.x(), vec.y(), vec.z());
 }
示例#9
0
 /**
  * Creates a new vector from the sum of this vector and the given vector.
  *
  * @param vec Vector for sum
  */
 public Vector plus(Vector vec) {
   return plus(vec.x(), vec.y(), vec.z());
 }
示例#10
0
 /**
  * Add the given vector to this vector.
  *
  * @param vec The vector to add
  * @return this
  */
 public Vector add(Vector vec) {
   return add(vec.x(), vec.y(), vec.z());
 }
示例#11
0
 /**
  * Set this vector to the given vector.
  *
  * @param vec Vector to set to
  * @return this
  */
 public Vector set(Vector vec) {
   set(vec.x(), vec.y(), vec.z());
   return this;
 }