Mega Code Archive

 
Categories / Android / Game
 

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];   } }