Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates. - Java java.lang

Java examples for java.lang:Math Function

Description

Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates.

Demo Code


//package com.java2s;

public class Main {
    /**/*from   w ww  . j  av  a  2 s.  c  om*/
     * Returns the Cartesian coordinate for one axis of a point that is defined
     * by a given triangle and two normalized barycentric (areal) coordinates.
     * 
     * @param value1
     *        The coordinate on one axis of vertex 1 of the defining
     *        triangle.
     * @param value2
     *        The coordinate on the same axis of vertex 2 of the defining
     *        triangle.
     * @param value3
     *        The coordinate on the same axis of vertex 3 of the defining
     *        triangle.
     * @param amount1
     *        The normalized barycentric (areal) coordinate b2, equal to the
     *        weighting factor for vertex 2, the coordinate of which is
     *        specified in value2.
     * @param amount2
     *        The normalized barycentric (areal) coordinate b3, equal to the
     *        weighting factor for vertex 3, the coordinate of which is
     *        specified in value3.
     * @return Cartesian coordinate of the specified point with respect to the
     *         axis being used.
     */
    public static float barycentric(float value1, float value2,
            float value3, float amount1, float amount2) {
        return value1 + (value2 - value1) * amount1 + (value3 - value1)
                * amount2;
    }
}

Related Tutorials