Java Vector Multiply vectorMult3D(float[] array, int vectorIndex, float scale)

Here you can find the source of vectorMult3D(float[] array, int vectorIndex, float scale)

Description

This method multiplies the given 3D vector by the specified scale amount.

License

Apache License

Parameter

Parameter Description
array The array which contains vectors.
vectorIndex The index of the vector to scale.
scale The value to scale the vector by.

Declaration

public static void vectorMult3D(float[] array, int vectorIndex, float scale) 

Method Source Code

//package com.java2s;
/* /*from   ww w. j  a  va2s . c  o  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 multiplies the given 3D vector by the specified scale amount.
     * @param array The array which contains vectors.
     * @param vectorIndex The index of the vector to scale.
     * @param scale The value to scale the vector by.
     */
    public static void vectorMult3D(float[] array, int vectorIndex, float scale) {
        int tempIndex = 3 * vectorIndex;
        array[tempIndex + 0] *= scale;
        array[tempIndex + 1] *= scale;
        array[tempIndex + 2] *= scale;
    }
}

Related

  1. vectorMatrixMultiply(double[][] matrix, double[] vector)
  2. vectorMult(final float[] result, final float[] m, final float[] v)
  3. vectorMultiply(double s, double[] v)