Java Array Multiply multiplyVector(float[] mat, float[] vec, float[] dest)

Here you can find the source of multiplyVector(float[] mat, float[] vec, float[] dest)

Description

multiply Vector

License

Open Source License

Declaration

public static float[] multiplyVector(float[] mat, float[] vec, float[] dest) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static float[] multiplyVector(float[] mat, float[] vec, float[] dest) {
        if (dest == null) {
            dest = vec;//from  w  ww .j  a v  a 2s  .  com
        }

        float vec0 = vec[0];
        float vec1 = vec[1];
        float vec2 = vec[2];
        float vec3 = vec[3];

        dest[0] = mat[0] * vec0 + mat[4] * vec1 + mat[8] * vec2 + mat[12] * vec3;
        dest[1] = mat[1] * vec0 + mat[5] * vec1 + mat[9] * vec2 + mat[13] * vec3;
        dest[2] = mat[2] * vec0 + mat[6] * vec1 + mat[10] * vec2 + mat[14] * vec3;
        dest[3] = mat[3] * vec0 + mat[7] * vec1 + mat[11] * vec2 + mat[15] * vec3;

        return dest;
    }
}

Related

  1. multiplySelf(double[] dest, double source)
  2. multiplySparse(int[][][] as, int A, int[][][] bs, int B, int[][][] cs)
  3. multiplySquares(float[] mat1, float[] mat2, int sidelength)
  4. multiplyValues(byte[] array, int multiplier)
  5. multiplyVecorWithScalar(double[] v, double s)
  6. multiplyVectorByMatrix(double[] v, double[] m, double[] result)
  7. multiplyX(long[] x, long[] z)
  8. multiplyX(long[] x, long[] z)