Subtracts two vectors (a-b). - Android java.lang

Android examples for java.lang:Math Vector

Description

Subtracts two vectors (a-b).

Demo Code


//package com.java2s;

public class Main {
    /**//from w w  w .  j a va  2  s  .  com
     * Subtracts two vectors (a-b).
     * @param a The first vector
     * @param b The second vector
     * @param result Storage for the result, if null, do nothing
     **/
    public static void sub(int size, float[] a, int offsetA, float[] b,
            int offsetB, float[] result, int offsetResult) {
        if (result == null) {
            return;
        }
        for (int i = 0; i < size; i++)
            result[offsetResult + i] = a[offsetA + i] - b[offsetB + i];
    }
}

Related Tutorials