Here you can find the source of vectorAdd3D(float[] array, int vectorIndex, float x, float y, float z)
Parameter | Description |
---|---|
array | The array which contains vectors. |
vectorIndex | The index of the vector to add to. |
x | The x component to add to the vector. |
y | The y component to add to the vector. |
z | The z component to add to the vector. |
public static void vectorAdd3D(float[] array, int vectorIndex, float x, float y, float z)
//package com.java2s; /* //from w w w . ja v a2 s. co m * Copyright 2014 Topeka Labs. * * 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 { /** * This method adds the given 3D vector to the vector specified in the array. * @param array The array which contains vectors. * @param vectorIndex The index of the vector to add to. * @param x The x component to add to the vector. * @param y The y component to add to the vector. * @param z The z component to add to the vector. */ public static void vectorAdd3D(float[] array, int vectorIndex, float x, float y, float z) { int tempIndex = 3 * vectorIndex; array[tempIndex] += x; array[tempIndex + 1] += y; array[tempIndex + 2] += z; } }