Homogenize a point (divide by its last element) - Android java.lang

Android examples for java.lang:Math Geometry

Description

Homogenize a point (divide by its last element)

Demo Code


//package com.java2s;

public class Main {
    /**/*from w  ww.  j  a  v a2s .c  o m*/
     * Homogenize a point (divide by its last element)
     * @param pt The point <b>Modified</b>
     **/
    public static void homogenize(int size, float[] pt, int offset) {
        multiply(size, pt, offset, 1 / pt[3]);
    }

    /**
     * Multiply a vector by a scalar.  <b>Modifies the input vector</b>
     * @param vector The vector 
     * @param scalar The scalar
     **/
    public static void multiply(int size, float[] vector, int offset,
            float scalar) {
        for (int i = 0; i < size; i++)
            vector[offset + i] *= scalar;
    }
}

Related Tutorials