Cross Product between list of Double value - Java java.lang

Java examples for java.lang:double Array

Description

Cross Product between list of Double value

Demo Code

/*// w  ww .jav a  2s  . co  m
 * VectorHelpers.java
 * Copyright (C) 2014 Amin Bandali <me@aminb.org>
 *
 * MATHTools is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MATHTools is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */
//package com.java2s;
import java.util.List;

public class Main {
    public static double[] calcCrossProduct(List<Double> in1,
            List<Double> in2) {
        double x = in1.get(1) * in2.get(2) - in2.get(1) * in1.get(2);
        double y = in1.get(2) * in2.get(0) - in2.get(2) * in1.get(0);
        double z = in1.get(0) * in2.get(1) - in2.get(0) * in1.get(1);
        return new double[] { x, y, z };
    }
}

Related Tutorials