Sha256: a563ca9c54fe6a6299fc30d55ac6ca936aaa0dc260671cc34d724abd89622a26

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

/*global define*/
define(['Core/barycentricCoordinates', 'Core/Cartesian3', 'Core/DeveloperError'], function(
        barycentricCoordinates,
        Cartesian3,
        DeveloperError) {
    "use strict";

    var coords = new Cartesian3();

    /**
     * Determines if a point is inside a triangle.
     *
     * @exports pointInsideTriangle
     *
     * @param {Cartesian2|Cartesian3} point The point to test.
     * @param {Cartesian2|Cartesian3} p0 The first point of the triangle.
     * @param {Cartesian2|Cartesian3} p1 The second point of the triangle.
     * @param {Cartesian2|Cartesian3} p2 The third point of the triangle.
     *
     * @returns {Boolean} <code>true</code> if the point is inside the triangle; otherwise, <code>false</code>.
     *
     * @exception {DeveloperError} point, p0, p1, and p2 are required.
     *
     * @example
     * // Returns true
     * var p = new Cartesian2(0.25, 0.25);
     * var b = pointInsideTriangle(p,
     *   new Cartesian2(0.0, 0.0),
     *   new Cartesian2(1.0, 0.0),
     *   new Cartesian2(0.0, 1.0));
     */
    var pointInsideTriangle = function(point, p0, p1, p2) {
        barycentricCoordinates(point, p0, p1, p2, coords);
        return (coords.x > 0.0) && (coords.y > 0.0) && (coords.z > 0);
    };

    return pointInsideTriangle;
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cesium-0.24.1 app/assets/javascripts/Core/pointInsideTriangle.js
cesium-0.24.0 app/assets/javascripts/Core/pointInsideTriangle.js
cesium-0.23.0 app/assets/javascripts/Core/pointInsideTriangle.js
cesium-0.22.0 app/assets/javascripts/Core/pointInsideTriangle.js
cesium-0.21.1 app/assets/javascripts/Core/pointInsideTriangle.js
cesium-0.21 app/assets/javascripts/Core/pointInsideTriangle.js
cesium-0.20.0 app/assets/javascripts/Core/pointInsideTriangle.js