Java Array Cross Product cross3(double x1, double y1, double z1, double x2, double y2, double z2)

Here you can find the source of cross3(double x1, double y1, double z1, double x2, double y2, double z2)

Description

cross

License

Open Source License

Declaration

public static double[] cross3(double x1, double y1, double z1, double x2, double y2, double z2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[] cross3(double x1, double y1, double z1, double x2, double y2, double z2) {
        double[] v = new double[3];
        v[0] = y1 * z2 - z1 * y2;/*from ww w  .j  a  v  a2s .  c o  m*/
        v[1] = z1 * x2 - x1 * z2;
        v[2] = x1 * y2 - y1 * x2;
        return v;
    }

    public static double[] cross3(double[] v1, double[] v2) {
        if (v1 == null)
            throw new NullPointerException("vec 1");
        if (v2 == null)
            throw new NullPointerException("vec 2");
        if (v1.length != 3)
            throw new IllegalArgumentException("vec 1");
        if (v2.length != 3)
            throw new IllegalArgumentException("vec 2");
        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(float[] v1, float[] v2, float[] out)
  2. cross(float[] vec1, float[] vec2)
  3. cross(int x1, int y1, int x2, int y2)
  4. cross2D(final float[] v1, final float[] v2)
  5. cross2D(int[] v, int[] u)
  6. cross33(float u[], float v[])
  7. crossEndForLineVectorAlgebra(double x1, double y1, double x2, double y2, double margin, double width)
  8. crossMuliply(double a, double b, double c)
  9. crossMult(int value, int maximum, int coefficient)