Here you can find the source of cross(final double[] left, final double[] right)
Parameter | Description |
---|---|
left | a vector of length 3 |
right | a vector of length 3 |
public static double[] cross(final double[] left, final double[] right)
//package com.java2s; /**/*from w w w . ja va2 s . co m*/ * ===================================================================== * This file is part of JSatTrak. * * Copyright 2007-2013 Shawn E. Gano * * 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 { /** * cross product or 2 3x1 vectors * * @param left a vector of length 3 * @param right a vector of length 3 * @return a cross b */ public static double[] cross(final double[] left, final double[] right) { if ((left.length != 3) || (right.length != 3)) { System.out.println("ERROR: Invalid dimension in Cross(Vector,Vector)"); } double[] Result = new double[3]; Result[0] = left[1] * right[2] - left[2] * right[1]; Result[1] = left[2] * right[0] - left[0] * right[2]; Result[2] = left[0] * right[1] - left[1] * right[0]; return Result; } }