Java Array Cross Product cross(double v0x, double v0y, double v1x, double v1y)

Here you can find the source of cross(double v0x, double v0y, double v1x, double v1y)

Description

Calculates the 'cross product' of two vectors.

License

Apache License

Parameter

Parameter Description
v0x a parameter
v0y a parameter
v1x a parameter
v1y a parameter

Declaration

public static double cross(double v0x, double v0y, double v1x, double v1y) 

Method Source Code

//package com.java2s;
/*/*from  w w  w .j a  va 2  s. co  m*/
 * Copyright 2011 Mark McKay
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Calculates the 'cross product' of two vectors.  This is the same as the
     * 3D version with the assumption that the vectors lie in the XY plane.  The
     * Z component of the cross product is returned.
     *
     * @param v0x
     * @param v0y
     * @param v1x
     * @param v1y
     * @return
     */
    public static double cross(double v0x, double v0y, double v1x, double v1y) {
        return v0x * v1y - v0y * v1x;
    }

    public static int cross(int v0x, int v0y, int v1x, int v1y) {
        return v0x * v1y - v0y * v1x;
    }
}

Related

  1. cross(double v1[], double v2[])
  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)