Java Array Cross Product cross(float[] vec1, float[] vec2)

Here you can find the source of cross(float[] vec1, float[] vec2)

Description

cross product vec1 x vec2

License

Open Source License

Parameter

Parameter Description
vec1 vector 1
vec2 vecttor 2

Return

the resulting vector

Declaration

public static float[] cross(float[] vec1, float[] vec2) 

Method Source Code

//package com.java2s;

public class Main {
    /** cross product vec1 x vec2
     * @param vec1 vector 1/*from w w w  .  j a v  a  2  s.c o m*/
     * @param vec2 vecttor 2
     * @return the resulting vector
     */
    public static float[] cross(float[] vec1, float[] vec2) {
        float[] out = new float[3];

        out[0] = vec2[2] * vec1[1] - vec2[1] * vec1[2];
        out[1] = vec2[0] * vec1[2] - vec2[2] * vec1[0];
        out[2] = vec2[1] * vec1[0] - vec2[0] * vec1[1];

        return out;
    }
}

Related

  1. cross(double[] p, double[] q)
  2. cross(double[] vec1, double[] vec2, double[] outvec)
  3. cross(final double[] a, final double[] b, final double[] c)
  4. cross(final double[] left, final double[] right)
  5. cross(float[] v1, float[] v2, float[] out)
  6. cross(int x1, int y1, int x2, int y2)
  7. cross2D(final float[] v1, final float[] v2)
  8. cross2D(int[] v, int[] u)
  9. cross3(double x1, double y1, double z1, double x2, double y2, double z2)