Compute the cross product of two vectors : Vector « Game « Android






Compute the cross product of two vectors

 
class Main {
  /**
   * Compute the cross product of two vectors
   * 
   * @param v1
   *            The first vector
   * @param v2
   *            The second vector
   * @param result
   *            Where to store the cross product
   **/
  public static void cross(float[] p1, float[] p2, float[] result) {
    result[0] = p1[1] * p2[2] - p2[1] * p1[2];
    result[1] = p1[2] * p2[0] - p2[2] * p1[0];
    result[2] = p1[0] * p2[1] - p2[0] * p1[1];
  }
}

   
  








Related examples in the same category

1.Wrapper activity demonstrating the use of the new SensorEvent rotation vector sensor, Sensor#TYPE_ROTATION_VECTOR TYPE_ROTATION_VECTOR}).
2.Vector2d structure
3.Vector2 Structure
4.Convenience library to do vector calculations
5.Vector3
6.Bit Vector
7.Compute the dot product of two vectors
8.Compute the magnitude (length) of a vector
9.Vector3 structure