Compute the cross product of two vectors - Android java.lang

Android examples for java.lang:Math Vector

Description

Compute the cross product of two vectors

Demo Code


//package com.java2s;

public class Main {
    /**//from w  ww.  j  a v  a2s .c  o  m
     * 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 cross3f(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 Tutorials