Java Array Cross Product cross(double v1[], double v2[])

Here you can find the source of cross(double v1[], double v2[])

Description

Calculates cross product of two vectors.

License

Academic Free License

Parameter

Parameter Description
v1 a parameter
v2 a parameter

Declaration

public static double[] cross(double v1[], double v2[]) 

Method Source Code

//package com.java2s;
//License from project: Academic Free License 

public class Main {
    /**//from   w ww  .  j a  va  2  s.c o m
     * Calculates cross product of two vectors.
     * 
     * @param v1
     * @param v2
     * @return
     */
    public static double[] cross(double v1[], double v2[]) {
        double v[] = new double[3];

        v[0] = v1[1] * v2[2] - v1[2] * v2[1];
        v[1] = v1[2] * v2[0] - v1[0] * v2[2];
        v[2] = v1[0] * v2[1] - v1[1] * v2[0];

        return v;
    }
}

Related

  1. cross(double v0x, double v0y, double v1x, double v1y)
  2. cross(double[] p, double[] q)
  3. cross(double[] vec1, double[] vec2, double[] outvec)
  4. cross(final double[] a, final double[] b, final double[] c)
  5. cross(final double[] left, final double[] right)