Java Vector Add vectorAdd(float[] v1, float[] v2)

Here you can find the source of vectorAdd(float[] v1, float[] v2)

Description

Adds to vectors

License

Open Source License

Parameter

Parameter Description
v1 vector 1
v2 vector 2

Return

v1 + v2

Declaration

public static float[] vectorAdd(float[] v1, float[] v2) 

Method Source Code

//package com.java2s;

public class Main {
    /** Adds to vectors/*  www . ja v  a2  s .com*/
     * @param v1 vector 1
     * @param v2 vector 2
     * @return v1 + v2
     */
    public static float[] vectorAdd(float[] v1, float[] v2) {
        float[] newVector = new float[3];

        newVector[0] = v1[0] + v2[0];
        newVector[1] = v1[1] + v2[1];
        newVector[2] = v1[2] + v2[2];
        return newVector;
    }
}

Related

  1. addAll(Vector vector, Object[] copyFrom)
  2. addArray(Vector vector, Object[] array)
  3. addToVector(Vector from, Vector to)
  4. vectorAdd(double[] v1, double[] v2)
  5. vectorAdd(double[] v1, double[] v2)
  6. vectorAdd3D(float[] array, int vectorIndex, float x, float y, float z)