1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
|
{"version":3,"file":"Plane-616c9c0a.js","sources":["../../../../Source/Core/Plane.js"],"sourcesContent":["import Cartesian3 from \"./Cartesian3.js\";\nimport Cartesian4 from \"./Cartesian4.js\";\nimport Check from \"./Check.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport CesiumMath from \"./Math.js\";\nimport Matrix4 from \"./Matrix4.js\";\n\n/**\n * A plane in Hessian Normal Form defined by\n * <pre>\n * ax + by + cz + d = 0\n * </pre>\n * where (a, b, c) is the plane's <code>normal</code>, d is the signed\n * <code>distance</code> to the plane, and (x, y, z) is any point on\n * the plane.\n *\n * @alias Plane\n * @constructor\n *\n * @param {Cartesian3} normal The plane's normal (normalized).\n * @param {Number} distance The shortest distance from the origin to the plane. The sign of\n * <code>distance</code> determines which side of the plane the origin\n * is on. If <code>distance</code> is positive, the origin is in the half-space\n * in the direction of the normal; if negative, the origin is in the half-space\n * opposite to the normal; if zero, the plane passes through the origin.\n *\n * @example\n * // The plane x=0\n * const plane = new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0);\n *\n * @exception {DeveloperError} Normal must be normalized\n */\nfunction Plane(normal, distance) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"normal\", normal);\n if (\n !CesiumMath.equalsEpsilon(\n Cartesian3.magnitude(normal),\n 1.0,\n CesiumMath.EPSILON6\n )\n ) {\n throw new DeveloperError(\"normal must be normalized.\");\n }\n Check.typeOf.number(\"distance\", distance);\n //>>includeEnd('debug');\n\n /**\n * The plane's normal.\n *\n * @type {Cartesian3}\n */\n this.normal = Cartesian3.clone(normal);\n\n /**\n * The shortest distance from the origin to the plane. The sign of\n * <code>distance</code> determines which side of the plane the origin\n * is on. If <code>distance</code> is positive, the origin is in the half-space\n * in the direction of the normal; if negative, the origin is in the half-space\n * opposite to the normal; if zero, the plane passes through the origin.\n *\n * @type {Number}\n */\n this.distance = distance;\n}\n\n/**\n * Creates a plane from a normal and a point on the plane.\n *\n * @param {Cartesian3} point The point on the plane.\n * @param {Cartesian3} normal The plane's normal (normalized).\n * @param {Plane} [result] The object onto which to store the result.\n * @returns {Plane} A new plane instance or the modified result parameter.\n *\n * @example\n * const point = Cesium.Cartesian3.fromDegrees(-72.0, 40.0);\n * const normal = ellipsoid.geodeticSurfaceNormal(point);\n * const tangentPlane = Cesium.Plane.fromPointNormal(point, normal);\n *\n * @exception {DeveloperError} Normal must be normalized\n */\nPlane.fromPointNormal = function (point, normal, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"point\", point);\n Check.typeOf.object(\"normal\", normal);\n if (\n !CesiumMath.equalsEpsilon(\n Cartesian3.magnitude(normal),\n 1.0,\n CesiumMath.EPSILON6\n )\n ) {\n throw new DeveloperError(\"normal must be normalized.\");\n }\n //>>includeEnd('debug');\n\n const distance = -Cartesian3.dot(normal, point);\n\n if (!defined(result)) {\n return new Plane(normal, distance);\n }\n\n Cartesian3.clone(normal, result.normal);\n result.distance = distance;\n return result;\n};\n\nconst scratchNormal = new Cartesian3();\n/**\n * Creates a plane from the general equation\n *\n * @param {Cartesian4} coefficients The plane's normal (normalized).\n * @param {Plane} [result] The object onto which to store the result.\n * @returns {Plane} A new plane instance or the modified result parameter.\n *\n * @exception {DeveloperError} Normal must be normalized\n */\nPlane.fromCartesian4 = function (coefficients, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"coefficients\"
|