@itwin/core-geometry 4.7.0-dev.9 → 4.8.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/lib/cjs/curve/Arc3d.d.ts +12 -0
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +29 -0
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.d.ts +15 -13
- package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Angle.js +24 -38
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +46 -13
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +78 -24
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +5 -0
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +10 -4
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +16 -4
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/solid/TorusPipe.d.ts +19 -12
- package/lib/cjs/solid/TorusPipe.d.ts.map +1 -1
- package/lib/cjs/solid/TorusPipe.js +27 -15
- package/lib/cjs/solid/TorusPipe.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +12 -0
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +29 -0
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts +15 -13
- package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
- package/lib/esm/geometry3d/Angle.js +24 -38
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +46 -13
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +78 -24
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +5 -0
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +10 -4
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +16 -4
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/solid/TorusPipe.d.ts +19 -12
- package/lib/esm/solid/TorusPipe.d.ts.map +1 -1
- package/lib/esm/solid/TorusPipe.js +27 -15
- package/lib/esm/solid/TorusPipe.js.map +1 -1
- package/package.json +3 -3
|
@@ -380,11 +380,12 @@ class Angle {
|
|
|
380
380
|
&& dotUV * dotUV <= Geometry_1.Geometry.smallAngleRadiansSquared * dotUU * dotVV;
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
|
-
*
|
|
384
|
-
* * This function assumes the input arguments are related to an angle between -PI and PI
|
|
385
|
-
* * This function returns an angle between -PI and PI
|
|
386
|
-
* @param rCos2A cosine value
|
|
387
|
-
* @param rSin2A sine value
|
|
383
|
+
* Compute the angle A given r*cos(2A) and r*sin(2A) for some nonnegative scalar r.
|
|
384
|
+
* * This function assumes the input arguments are related to an angle between -PI and PI.
|
|
385
|
+
* * This function returns an angle between -PI and PI.
|
|
386
|
+
* @param rCos2A scaled cosine value of twice the angle A.
|
|
387
|
+
* @param rSin2A scaled sine value of twice the angle A.
|
|
388
|
+
* @return cos(A), sin(A) and A in radians
|
|
388
389
|
*/
|
|
389
390
|
static trigValuesToHalfAngleTrigValues(rCos2A, rSin2A) {
|
|
390
391
|
const r = Geometry_1.Geometry.hypotenuseXY(rCos2A, rSin2A);
|
|
@@ -394,41 +395,25 @@ class Angle {
|
|
|
394
395
|
else {
|
|
395
396
|
/* If the caller really gave you sine and cosine values, r should be 1. However,
|
|
396
397
|
* to allow scaled values -- e.g. the x and y components of any vector -- we normalize
|
|
397
|
-
* right here. This adds an extra sqrt and
|
|
398
|
+
* right here. This adds an extra sqrt and two divisions, but improves
|
|
398
399
|
* both the usefulness and robustness of the computation.
|
|
399
400
|
*/
|
|
400
401
|
let cosA;
|
|
401
402
|
let sinA = 0.0;
|
|
402
403
|
const cos2A = rCos2A / r;
|
|
403
404
|
const sin2A = rSin2A / r;
|
|
404
|
-
//
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
* We know cos2A = (cosA)^2 - (sinA)^2 and 1 = (cosA)^2 + (sinA)^2
|
|
408
|
-
* so 1 + cos2A = 2(cosA)^2 and therefore, cosA = sqrt((1+cos2A)/2)
|
|
409
|
-
* cosine is positive in NE and SE quadrants so we use +sqrt
|
|
410
|
-
*/
|
|
411
|
-
cosA = Math.sqrt(0.5 * (1.0 + cos2A));
|
|
412
|
-
// We know sin2A = 2 sinA cosA so sinA = sin2A/(2*cosA)
|
|
413
|
-
sinA = sin2A / (2.0 * cosA);
|
|
405
|
+
if (cos2A >= 0.0) { // 2A is in NE and SE quadrants, A in same quadrant
|
|
406
|
+
cosA = Math.sqrt(0.5 * (1.0 + cos2A)); // half angle formula. Use +root since cosA >= 0
|
|
407
|
+
sinA = sin2A / (2.0 * cosA); // double angle formula
|
|
414
408
|
}
|
|
415
409
|
else {
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
/*
|
|
419
|
-
* We know cos2A = (cosA)^2 - (sinA)^2 and 1 = (cosA)^2 + (sinA)^2
|
|
420
|
-
* so 1 - cos2A = 2(sinA)^2 and therefore, sinA = sqrt((1-cos2A)/2)
|
|
421
|
-
* sine is positive in NE quadrant so we use +sqrt
|
|
422
|
-
*/
|
|
423
|
-
sinA = Math.sqrt(0.5 * (1.0 - cos2A));
|
|
424
|
-
// Original angle in SW quadrant. Half angle in SE quadrant
|
|
410
|
+
if (sin2A > 0.0) { // 2A in NW quadrant. A in NE quadrant
|
|
411
|
+
sinA = Math.sqrt(0.5 * (1.0 - cos2A)); // half angle formula. Use +root since sinA > 0
|
|
425
412
|
}
|
|
426
|
-
else {
|
|
427
|
-
|
|
428
|
-
sinA = -Math.sqrt(0.5 * (1.0 - cos2A));
|
|
413
|
+
else { // 2A in SW quadrant. A in SE quadrant
|
|
414
|
+
sinA = -Math.sqrt(0.5 * (1.0 - cos2A)); // half angle formula. Use -root since sinA <= 0
|
|
429
415
|
}
|
|
430
|
-
|
|
431
|
-
cosA = sin2A / (2.0 * sinA); // always positive
|
|
416
|
+
cosA = sin2A / (2.0 * sinA); // double angle formula
|
|
432
417
|
}
|
|
433
418
|
return { c: cosA, s: sinA, radians: Math.atan2(sinA, cosA) };
|
|
434
419
|
}
|
|
@@ -447,18 +432,19 @@ class Angle {
|
|
|
447
432
|
return value;
|
|
448
433
|
}
|
|
449
434
|
/**
|
|
450
|
-
* Return the half angle cosine, sine, and radians for given dot products
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* * Given ellipse x(t) = c + U cos(t) + V sin(t), find t0 such that radial vector W(t0) = x(t0) - c is
|
|
455
|
-
* perpendicular to the ellipse.
|
|
435
|
+
* Return the half angle cosine, sine, and radians for the given vector dot products.
|
|
436
|
+
* * These values arise e.g. in the computation performed in `Arc3d.toScaledMatrix3d`.
|
|
437
|
+
* * Let vectors U and V define the ellipse x(t) = c + U cos(t) + V sin(t). We seek an angle t0
|
|
438
|
+
* such that the radial vector W(t0) := x(t0) - c is perpendicular to the ellipse.
|
|
456
439
|
* * Then 0 = W(t0).x'(t0) = (U cos(t0) + V sin(t0)).(V cos(t0) - U sin(t0)) = U.V cos(2t0) + 0.5 (V.V - U.U) sin(2t0)
|
|
457
|
-
* implies sin(2t0) / cos(2t0) = 2 U.V / (U.U - V.V), i.e., t0 can be computed given the
|
|
458
|
-
*
|
|
440
|
+
* implies tan(2t0) = sin(2t0) / cos(2t0) = 2 U.V / (U.U - V.V), i.e., t0 can be computed given the input dot products.
|
|
441
|
+
* Math details can be found at docs/learning/geometry/Angle.md
|
|
459
442
|
* @param dotUU dot product of vectorU with itself
|
|
460
443
|
* @param dotVV dot product of vectorV with itself
|
|
461
444
|
* @param dotUV dot product of vectorU with vectorV
|
|
445
|
+
* @param favorZero whether to allow a tight tolerance for returning t0 = 0 (default true).
|
|
446
|
+
* When dotUV is near zero, U and V are nearly perpendicular, and the returned angle is near zero.
|
|
447
|
+
* @return the angle t0 and its cosine and sine.
|
|
462
448
|
*/
|
|
463
449
|
static dotProductsToHalfAngleTrigValues(dotUU, dotVV, dotUV, favorZero = true) {
|
|
464
450
|
const cos2t0 = dotUU - dotVV;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Angle.js","sourceRoot":"","sources":["../../../src/geometry3d/Angle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAa,KAAK;IAiBhB,YAAoB,OAAO,GAAG,CAAC,EAAE,OAAgB;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,gDAAgD;IACzC,KAAK;QACV,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IACD,8CAA8C;IACvC,MAAM;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,aAAa,CAAC,OAAe;QACzC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO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BAC5E,OAAO,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IACD;;;OAGG;IACI,uBAAuB,CAAC,QAAgB;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG,KAAK,CAAC;YAClC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC;QAC/C,CAAC;IACH,CAAC;;AAhhBH,sBAihBC;AAhhBC,+DAA+D;AACxC,qBAAe,GAAG,mBAAmB,CAAC;AAC7D,8DAA8D;AACvC,oBAAc,GAAG,sBAAsB,CAAC;AAC/D,8DAA8D;AACvC,oBAAc,GAAG,uBAAuB,CAAC;AAChE,6DAA6D;AACtC,eAAS,GAAG,sBAAsB,CAAC;AAC1D,+DAA+D;AACxC,gBAAU,GAAG,sBAAsB,CAAC;AAC3D,qDAAqD;AAC9B,sBAAgB,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AACxE,qDAAqD;AAC9B,sBAAgB,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { AngleProps, BeJSONFunctions, Geometry, TrigValues } from \"../Geometry\";\r\n\r\n/**\r\n * An `Angle` carries the numeric value of an angle, with methods to allow (require!) callers to\r\n * be clear about whether their angle is degrees or radians.\r\n * * After the Angle object is created, the callers should not know or care whether it is stored in\r\n * `degrees` or `radians` because both are available if requested by caller.\r\n * * The various access method are named so that callers can specify whether untyped numbers passed in or\r\n * out are degrees or radians.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/AngleSweep\r\n * @public\r\n */\r\nexport class Angle implements BeJSONFunctions {\r\n /** maximal accuracy value of pi/12 (15 degrees), in radians */\r\n public static readonly piOver12Radians = 0.26179938779914946;\r\n /** maximal accuracy value of pi/4 (45 degrees), in radians */\r\n public static readonly piOver4Radians = 7.853981633974483e-001;\r\n /** maximal accuracy value of pi/2 (90 degrees), in radians */\r\n public static readonly piOver2Radians = 1.5707963267948966e+000;\r\n /** maximal accuracy value of pi (180 degrees), in radians */\r\n public static readonly piRadians = 3.141592653589793e+000;\r\n /** maximal accuracy value of 2*pi (360 degrees), in radians */\r\n public static readonly pi2Radians = 6.283185307179586e+000;\r\n /** scale factor for converting radians to degrees */\r\n public static readonly degreesPerRadian = (45.0 / Angle.piOver4Radians);\r\n /** scale factor for converting degrees to radians */\r\n public static readonly radiansPerDegree = (Angle.piOver4Radians / 45.0);\r\n private _radians: number;\r\n private _degrees?: number;\r\n private constructor(radians = 0, degrees?: number) {\r\n this._radians = radians;\r\n this._degrees = degrees;\r\n }\r\n /** Return a new angle with the same content. */\r\n public clone(): Angle {\r\n return new Angle(this._radians, this._degrees);\r\n }\r\n /** Freeze this instance so it is read-only */\r\n public freeze(): Readonly<this> {\r\n return Object.freeze(this);\r\n }\r\n /**\r\n * Return a new Angle object for angle given in degrees.\r\n * @param degrees angle in degrees\r\n */\r\n public static createDegrees(degrees: number): Angle {\r\n return new Angle(Angle.degreesToRadians(degrees), degrees);\r\n }\r\n /**\r\n * Return a (new) Angle object for a value given in radians.\r\n * @param radians angle in radians\r\n */\r\n public static createRadians(radians: number): Angle {\r\n return new Angle(radians);\r\n }\r\n /**\r\n * Return a new `Angle` object with the default \"small\" angle measurement specified by [[Geometry.smallAngleRadians]].\r\n */\r\n public static createSmallAngle(): Angle {\r\n return new Angle(Geometry.smallAngleRadians);\r\n }\r\n /**\r\n * Return a (new) Angle object that is interpolated between two inputs (based on a fraction)\r\n * @param angle0 first angle in radians\r\n * @param fraction the interpolation fraction\r\n * @param angle1 second angle in radians\r\n */\r\n public static createInterpolate(angle0: Angle, fraction: number, angle1: Angle): Angle {\r\n return new Angle(Geometry.interpolate(angle0.radians, fraction, angle1.radians));\r\n }\r\n /**\r\n * Return a (new) Angle object, with angle scaled from existing angle.\r\n * @param scale scale factor to apply to angle.\r\n */\r\n public cloneScaled(scale: number): Angle {\r\n return new Angle(this.radians * scale);\r\n }\r\n /**\r\n * Set this angle to a value given in radians.\r\n * @param radians angle given in radians\r\n */\r\n public setRadians(radians: number) {\r\n this._radians = radians;\r\n this._degrees = undefined;\r\n }\r\n /**\r\n * Set this angle to a value given in degrees.\r\n * @param degrees angle given in degrees.\r\n */\r\n public setDegrees(degrees: number) {\r\n this._radians = Angle.degreesToRadians(degrees);\r\n this._degrees = degrees;\r\n }\r\n /** Create an angle for a full circle. */\r\n public static create360(): Angle {\r\n return new Angle(Math.PI * 2.0, 360.0);\r\n }\r\n /**\r\n * Create a (strongly typed) Angle whose tangent is `numerator/denominator`, using the signs of both in\r\n * determining the (otherwise ambiguous) quadrant.\r\n * @param numerator numerator for tangent\r\n * @param denominator denominator for tangent\r\n */\r\n public static createAtan2(numerator: number, denominator: number): Angle {\r\n return new Angle(Math.atan2(numerator, denominator));\r\n }\r\n /**\r\n * Copy all contents of `other` to this Angle.\r\n * @param other source data\r\n */\r\n public setFrom(other: Angle) {\r\n this._radians = other._radians;\r\n this._degrees = other._degrees;\r\n }\r\n /**\r\n * Set an Angle from a JSON object\r\n * * A simple number is considered as degrees.\r\n * * specified `json.degrees` or `json._degrees` is degree value.\r\n * * specified `son.radians` or `json._radians` is radians value.\r\n * @param json object from JSON.parse. If a number, value is in *DEGREES*\r\n * @param defaultValRadians if json is undefined, default value in radians.\r\n */\r\n public setFromJSON(json?: AngleProps, defaultValRadians?: number) {\r\n this._radians = defaultValRadians ? defaultValRadians : 0;\r\n if (!json)\r\n return;\r\n if (typeof json === \"number\") {\r\n this.setDegrees(json);\r\n } else if (typeof (json as any).degrees === \"number\") {\r\n this.setDegrees((json as any).degrees);\r\n } else if (typeof (json as any)._degrees === \"number\") {\r\n this.setDegrees((json as any)._degrees);\r\n } else if (typeof (json as any).radians === \"number\") {\r\n this.setRadians((json as any).radians);\r\n } else if (typeof (json as any)._radians === \"number\") {\r\n this.setRadians((json as any)._radians);\r\n }\r\n }\r\n /**\r\n * Create an Angle from a JSON object\r\n * @param json object from JSON.parse. If a number, value is in *DEGREES*\r\n * @param defaultValRadians if json is undefined, default value in radians.\r\n * @return a new Angle\r\n */\r\n public static fromJSON(json?: AngleProps, defaultValRadians?: number): Angle {\r\n const val = new Angle();\r\n val.setFromJSON(json, defaultValRadians);\r\n return val;\r\n }\r\n /** Convert an Angle to a JSON object as a number in degrees */\r\n public toJSON(): AngleProps {\r\n return this.degrees;\r\n }\r\n /** Return a json object with radians keyword, e.g. `{ radians: 0.10}` */\r\n public toJSONRadians(): AngleProps {\r\n return { radians: this.radians };\r\n }\r\n /** Return the angle measured in radians. */\r\n public get radians(): number {\r\n return this._radians;\r\n }\r\n /** Return the angle measured in degrees. */\r\n public get degrees(): number {\r\n return this._degrees !== undefined ? this._degrees : Angle.radiansToDegrees(this._radians);\r\n }\r\n /**\r\n * Convert an angle in degrees to radians.\r\n * @param degrees angle in degrees\r\n */\r\n public static degreesToRadians(degrees: number): number {\r\n return degrees * Math.PI / 180;\r\n }\r\n /**\r\n * Convert an angle in radians to degrees.\r\n * @param degrees angle in radians\r\n */\r\n public static radiansToDegrees(radians: number): number {\r\n if (radians < 0)\r\n return -Angle.radiansToDegrees(-radians);\r\n // Now radians is positive ...\r\n const pi = Math.PI;\r\n const factor = 180.0 / pi;\r\n /* the following if statements are for round-off reasons. The problem is that no IEEE number is\r\n * an exact hit for any primary multiple of pi (90, 180, etc). The following is supposed to have\r\n * a better chance that if the input was computed by direct assignment from 90, 180, etc degrees\r\n * it will return exactly 90,180 etc.\r\n */\r\n if (radians <= 0.25 * pi)\r\n return factor * radians;\r\n if (radians < 0.75 * pi)\r\n return 90.0 + 180 * ((radians - 0.5 * pi) / pi);\r\n if (radians <= 1.25 * pi)\r\n return 180.0 + 180 * ((radians - pi) / pi);\r\n if (radians <= 1.75 * pi)\r\n return 270.0 + 180 * ((radians - 1.5 * pi) / pi);\r\n // all larger radians reference from 360 degrees (2PI)\r\n return 360.0 + 180 * ((radians - 2.0 * pi) / pi);\r\n }\r\n /** Return the cosine of this Angle object's angle */\r\n public cos(): number {\r\n return Math.cos(this._radians);\r\n }\r\n /** Return the sine of this Angle object's angle */\r\n public sin(): number {\r\n return Math.sin(this._radians);\r\n }\r\n /** Return the tangent of this Angle object's angle */\r\n public tan(): number {\r\n return Math.tan(this._radians);\r\n }\r\n /** Test if a radians (absolute) value is nearly 2PI or larger! */\r\n public static isFullCircleRadians(radians: number): boolean {\r\n return Math.abs(radians) >= Geometry.fullCircleRadiansMinusSmallAngle;\r\n }\r\n /** Test if the radians value is a half circle */\r\n public static isHalfCircleRadians(radians: number): boolean {\r\n return Math.abs(Math.abs(radians) - Math.PI) <= Geometry.smallAngleRadians;\r\n }\r\n /** Test if the angle is a full circle */\r\n public get isFullCircle(): boolean {\r\n return Angle.isFullCircleRadians(this._radians);\r\n }\r\n /** Test if the angle is a half circle (in either direction) */\r\n public get isHalfCircle(): boolean {\r\n return Angle.isHalfCircleRadians(this._radians);\r\n }\r\n /** Adjust a radians value so it is positive in 0..360 */\r\n public static adjustDegrees0To360(degrees: number): number {\r\n if (degrees >= 0) {\r\n const period = 360.0;\r\n if (degrees < period)\r\n return degrees;\r\n const numPeriods = Math.floor(degrees / period);\r\n return degrees - numPeriods * period;\r\n } else if (degrees < 0) {\r\n // negative angle ...\r\n const radians = Angle.adjustDegrees0To360(-degrees);\r\n return 360.0 - radians;\r\n }\r\n // fall through for Nan (disaster) !!!\r\n return 0;\r\n }\r\n /** Adjust a radians value so it is in -180..180 */\r\n public static adjustDegreesSigned180(degrees: number): number {\r\n if (Math.abs(degrees) <= 180.0)\r\n return degrees;\r\n if (degrees >= 0) {\r\n const period = 360.0;\r\n const numPeriods = 1 + Math.floor((degrees - 180.0) / period);\r\n return degrees - numPeriods * period;\r\n } else if (degrees < 0) {\r\n // negative angle ...\r\n return -Angle.adjustDegreesSigned180(-degrees);\r\n }\r\n // fall through for NaN disaster.\r\n return 0;\r\n }\r\n /** Adjust a radians value so it is positive in 0..2Pi */\r\n public static adjustRadians0To2Pi(radians: number): number {\r\n if (radians >= 0) {\r\n const period = Math.PI * 2.0;\r\n if (radians < period)\r\n return radians;\r\n const numPeriods = Math.floor(radians / period);\r\n return radians - numPeriods * period;\r\n } else if (radians < 0) {\r\n // negative angle ...\r\n return Math.PI * 2.0 - Angle.adjustRadians0To2Pi(-radians);\r\n }\r\n // fall through for NaN disaster.\r\n return 0;\r\n }\r\n /** Adjust a radians value so it is positive in -PI..PI */\r\n public static adjustRadiansMinusPiPlusPi(radians: number): number {\r\n if (Math.abs(radians) <= Math.PI)\r\n return radians;\r\n if (radians >= 0) {\r\n const period = Math.PI * 2.0;\r\n const numPeriods = 1 + Math.floor((radians - Math.PI) / period);\r\n return radians - numPeriods * period;\r\n } else if (radians < 0) {\r\n // negative angle ...\r\n return -Angle.adjustRadiansMinusPiPlusPi(-radians);\r\n }\r\n // fall through for NaN disaster.\r\n return 0;\r\n }\r\n /** Return a (newly allocated) Angle object with value 0 radians */\r\n public static zero(): Angle {\r\n return new Angle(0);\r\n }\r\n /** Test if the angle is exactly zero. */\r\n public get isExactZero(): boolean {\r\n return this.radians === 0;\r\n }\r\n /** Test if the angle is almost zero (within tolerance `Geometry.smallAngleRadians`) */\r\n public get isAlmostZero(): boolean {\r\n return Math.abs(this.radians) < Geometry.smallAngleRadians;\r\n }\r\n /** Test if the angle is almost a north or south pole (within tolerance `Geometry.smallAngleRadians`) */\r\n public get isAlmostNorthOrSouthPole(): boolean {\r\n return Angle.isHalfCircleRadians(this.radians * 2.0);\r\n }\r\n /** Create an angle object with degrees adjusted into 0..360. */\r\n public static createDegreesAdjustPositive(degrees: number): Angle {\r\n return Angle.createDegrees(Angle.adjustDegrees0To360(degrees));\r\n }\r\n /** Create an angle object with degrees adjusted into -180..180. */\r\n public static createDegreesAdjustSigned180(degrees: number): Angle {\r\n return Angle.createDegrees(Angle.adjustDegreesSigned180(degrees));\r\n }\r\n /**\r\n * Test if two radians values are equivalent, allowing shift by full circle (i.e. by a multiple of `2*PI`)\r\n * @param radiansA first radians value\r\n * @param radiansB second radians value\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public static isAlmostEqualRadiansAllowPeriodShift(radiansA: number, radiansB: number,\r\n radianTol: number = Geometry.smallAngleRadians): boolean {\r\n const delta = Math.abs(radiansA - radiansB);\r\n if (delta <= radianTol)\r\n return true;\r\n const period = Math.PI * 2.0;\r\n if (Math.abs(delta - period) <= radianTol)\r\n return true;\r\n const numPeriod = Math.round(delta / period);\r\n const delta1 = delta - numPeriod * period;\r\n return Math.abs(delta1) <= radianTol;\r\n }\r\n /**\r\n * Test if this angle has magnitude no greater than that of `other`.\r\n * @param other the other angle\r\n */\r\n public isMagnitudeLessThanOrEqual(other: Angle): boolean {\r\n return Math.abs(this.radians) <= Math.abs(other.radians);\r\n }\r\n\r\n /**\r\n * Test if this angle and other are equivalent, allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * @param other the other angle\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public isAlmostEqualAllowPeriodShift(other: Angle, radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return Angle.isAlmostEqualRadiansAllowPeriodShift(this._radians, other._radians, radianTol);\r\n }\r\n /**\r\n * Test if two angle (in radians) almost equal, NOT allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * @param radiansA first radians value\r\n * @param radiansB second radians value\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public static isAlmostEqualRadiansNoPeriodShift(radiansA: number, radiansB: number,\r\n radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return Math.abs(radiansA - radiansB) < radianTol;\r\n }\r\n /**\r\n * Test if two this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * @param other the other angle\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public isAlmostEqualNoPeriodShift(other: Angle, radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return Angle.isAlmostEqualRadiansNoPeriodShift(this._radians, other._radians, radianTol);\r\n }\r\n /**\r\n * Test if two this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * * This function is same as isAlmostEqualRadiansNoPeriodShift. Please use isAlmostEqualRadiansNoPeriodShift.\r\n * @param other the other angle\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public isAlmostEqual(other: Angle, radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return this.isAlmostEqualNoPeriodShift(other, radianTol);\r\n }\r\n /**\r\n * Test if dot product values indicate non-zero length perpendicular vectors.\r\n * @param dotUU dot product of vectorU with itself\r\n * @param dotVV dot product of vectorV with itself\r\n * @param dotUV dot product of vectorU with vectorV\r\n */\r\n public static isPerpendicularDotSet(dotUU: number, dotVV: number, dotUV: number): boolean {\r\n return dotUU > Geometry.smallMetricDistanceSquared\r\n && dotVV > Geometry.smallMetricDistanceSquared\r\n && dotUV * dotUV <= Geometry.smallAngleRadiansSquared * dotUU * dotVV;\r\n }\r\n /**\r\n * Return cosine, sine, and radians for the half angle of a \"cosine,sine\" pair.\r\n * * This function assumes the input arguments are related to an angle between -PI and PI\r\n * * This function returns an angle between -PI and PI\r\n * @param rCos2A cosine value (scaled by radius) for initial angle.\r\n * @param rSin2A sine value (scaled by radius) for final angle.\r\n */\r\n public static trigValuesToHalfAngleTrigValues(rCos2A: number, rSin2A: number): TrigValues {\r\n const r = Geometry.hypotenuseXY(rCos2A, rSin2A);\r\n if (r < Geometry.smallMetricDistance) {\r\n return { c: 1.0, s: 0.0, radians: 0.0 }; // angle = 0\r\n } else {\r\n /* If the caller really gave you sine and cosine values, r should be 1. However,\r\n * to allow scaled values -- e.g. the x and y components of any vector -- we normalize\r\n * right here. This adds an extra sqrt and 2 divides to the whole process, but improves\r\n * both the usefulness and robustness of the computation.\r\n */\r\n let cosA;\r\n let sinA = 0.0;\r\n const cos2A = rCos2A / r;\r\n const sin2A = rSin2A / r;\r\n // Original angle in NE and SE quadrants. Half angle in same quadrant\r\n if (cos2A >= 0.0) {\r\n /*\r\n * We know cos2A = (cosA)^2 - (sinA)^2 and 1 = (cosA)^2 + (sinA)^2\r\n * so 1 + cos2A = 2(cosA)^2 and therefore, cosA = sqrt((1+cos2A)/2)\r\n * cosine is positive in NE and SE quadrants so we use +sqrt\r\n */\r\n cosA = Math.sqrt(0.5 * (1.0 + cos2A));\r\n // We know sin2A = 2 sinA cosA so sinA = sin2A/(2*cosA)\r\n sinA = sin2A / (2.0 * cosA);\r\n } else {\r\n // Original angle in NW quadrant. Half angle in NE quadrant\r\n if (sin2A > 0.0) {\r\n /*\r\n * We know cos2A = (cosA)^2 - (sinA)^2 and 1 = (cosA)^2 + (sinA)^2\r\n * so 1 - cos2A = 2(sinA)^2 and therefore, sinA = sqrt((1-cos2A)/2)\r\n * sine is positive in NE quadrant so we use +sqrt\r\n */\r\n sinA = Math.sqrt(0.5 * (1.0 - cos2A));\r\n // Original angle in SW quadrant. Half angle in SE quadrant\r\n } else {\r\n // sine is negative in SE quadrant so we use -sqrt\r\n sinA = -Math.sqrt(0.5 * (1.0 - cos2A));\r\n }\r\n // We know sin2A = 2 sinA cosA so cosA = sin2A/(2*sinA)\r\n cosA = sin2A / (2.0 * sinA); // always positive\r\n }\r\n return { c: cosA, s: sinA, radians: Math.atan2(sinA, cosA) };\r\n }\r\n }\r\n /** If value is close to -1, -0.5, 0, 0.5, 1, adjust it to the exact value. */\r\n public static cleanupTrigValue(value: number, tolerance: number = Geometry.smallFloatingPoint): number {\r\n const absValue = Math.abs(value);\r\n if (absValue <= tolerance)\r\n return 0;\r\n let a = Math.abs(absValue - 0.5);\r\n if (a <= tolerance)\r\n return value < 0.0 ? -0.5 : 0.5;\r\n a = Math.abs(absValue - 1.0);\r\n if (a <= tolerance)\r\n return value < 0.0 ? -1.0 : 1.0;\r\n return value;\r\n }\r\n /**\r\n * Return the half angle cosine, sine, and radians for given dot products between vectors. The vectors define\r\n * an ellipse using x(t) = c + U cos(t) + V sin(t) so U and V are at angle t=0 degree and t=90 degree. The\r\n * half angle t0 is an angle such that x(t0) is one of the ellipse semi-axis.\r\n * * This construction arises e.g. in `Arc3d.toScaledMatrix3d`.\r\n * * Given ellipse x(t) = c + U cos(t) + V sin(t), find t0 such that radial vector W(t0) = x(t0) - c is\r\n * perpendicular to the ellipse.\r\n * * Then 0 = W(t0).x'(t0) = (U cos(t0) + V sin(t0)).(V cos(t0) - U sin(t0)) = U.V cos(2t0) + 0.5 (V.V - U.U) sin(2t0)\r\n * implies sin(2t0) / cos(2t0) = 2 U.V / (U.U - V.V), i.e., t0 can be computed given the three dot products on the RHS.\r\n * math details can be found at docs/learning/geometry/Angle.md\r\n * @param dotUU dot product of vectorU with itself\r\n * @param dotVV dot product of vectorV with itself\r\n * @param dotUV dot product of vectorU with vectorV\r\n */\r\n public static dotProductsToHalfAngleTrigValues(\r\n dotUU: number, dotVV: number, dotUV: number, favorZero: boolean = true,\r\n ): TrigValues {\r\n\r\n const cos2t0 = dotUU - dotVV;\r\n const sin2t0 = 2.0 * dotUV;\r\n if (favorZero && Math.abs(sin2t0) < Geometry.smallAngleRadians * (Math.abs(dotUU) + Math.abs(dotVV)))\r\n return { c: 1.0, s: 0.0, radians: 0.0 };\r\n return Angle.trigValuesToHalfAngleTrigValues(cos2t0, sin2t0);\r\n }\r\n /**\r\n * Returns the angle between two vectors, with the vectors given as xyz components\r\n * * The returned angle is between 0 and PI\r\n * @param ux x component of vector u\r\n * @param uy y component of vector u\r\n * @param uz z component of vector u\r\n * @param vx x component of vector v\r\n * @param vy y component of vector v\r\n * @param vz z component of vector v\r\n */\r\n public static radiansBetweenVectorsXYZ(\r\n ux: number, uy: number, uz: number, vx: number, vy: number, vz: number,\r\n ): number {\r\n const uDotV = ux * vx + uy * vy + uz * vz;\r\n return Math.atan2(Geometry.crossProductMagnitude(ux, uy, uz, vx, vy, vz), uDotV);\r\n }\r\n /**\r\n * Returns the angle between two vectors, with the vectors given as xyz components, and an up vector to resolve\r\n * angle to a full 2PI range.\r\n * * The returned angle is (-PI < radians <= PI) or (0 <= radians < 2 * PI)\r\n * * The angle is in the plane of the U and V vectors.\r\n * * The upVector determines a positive side of the plane but need not be strictly perpendicular to the plane.\r\n * @param ux x component of vector u\r\n * @param uy y component of vector u\r\n * @param uz z component of vector u\r\n * @param vx x component of vector v\r\n * @param vy y component of vector v\r\n * @param vz z component of vector v\r\n * @param upVectorX x component of vector to positive side of plane.\r\n * @param upVectorY y component of vector to positive side of plane.\r\n * @param upVectorZ z component of vector to positive side of plane.\r\n * @param adjustToAllPositive if true, return strictly non-negative sweep (0 <= radians < 2*PI). If false, return\r\n * signed (-PI < radians <= PI)\r\n */\r\n public static orientedRadiansBetweenVectorsXYZ(\r\n ux: number, uy: number, uz: number,\r\n vx: number, vy: number, vz: number,\r\n upVectorX: number, upVectorY: number, upVectorZ: number,\r\n adjustToPositive: boolean = false,\r\n ): number {\r\n const uDotV = ux * vx + uy * vy + uz * vz;\r\n const wx = uy * vz - uz * vy;\r\n const wy = uz * vx - ux * vz;\r\n const wz = ux * vy - uy * vx;\r\n const upDotW = upVectorX * wx + upVectorY * wy + upVectorZ * wz;\r\n const crossMagnitude = Geometry.hypotenuseXYZ(wx, wy, wz);\r\n if (upDotW < 0.0) {\r\n if (adjustToPositive) {\r\n // The turn is greater than 180 degrees. Take a peculiarly oriented atan2 to get the excess-180 part as\r\n // addition to PI. This gives the smoothest numerical transition passing PI.\r\n return Math.PI + Math.atan2(crossMagnitude, -uDotV);\r\n } else {\r\n return -Math.atan2(crossMagnitude, uDotV);\r\n }\r\n } else {\r\n return Math.atan2(crossMagnitude, uDotV);\r\n }\r\n }\r\n /**\r\n * Add a multiple of a full circle angle (360 degrees, 2PI) in place.\r\n * @param multiple multiplier factor\r\n */\r\n public addMultipleOf2PiInPlace(multiple: number) {\r\n if (this._degrees !== undefined) {\r\n this._degrees += multiple * 360.0;\r\n this._radians = Angle.degreesToRadians(this._degrees);\r\n } else {\r\n this._radians += multiple * Angle.pi2Radians;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Angle.js","sourceRoot":"","sources":["../../../src/geometry3d/Angle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAa,KAAK;IAiBhB,YAAoB,OAAO,GAAG,CAAC,EAAE,OAAgB;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IACD,gDAAgD;IACzC,KAAK;QACV,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IACD,8CAA8C;IACvC,MAAM;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,aAAa,CAAC,OAAe;QACzC,OAAO,IAAI,KAAK,CAAC,K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AA4E;gBAC5E,OAAO,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IACD;;;OAGG;IACI,uBAAuB,CAAC,QAAgB;QAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG,KAAK,CAAC;YAClC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC;QAC/C,CAAC;IACH,CAAC;;AAjgBH,sBAkgBC;AAjgBC,+DAA+D;AACxC,qBAAe,GAAG,mBAAmB,CAAC;AAC7D,8DAA8D;AACvC,oBAAc,GAAG,sBAAsB,CAAC;AAC/D,8DAA8D;AACvC,oBAAc,GAAG,uBAAuB,CAAC;AAChE,6DAA6D;AACtC,eAAS,GAAG,sBAAsB,CAAC;AAC1D,+DAA+D;AACxC,gBAAU,GAAG,sBAAsB,CAAC;AAC3D,qDAAqD;AAC9B,sBAAgB,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AACxE,qDAAqD;AAC9B,sBAAgB,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\n\r\nimport { AngleProps, BeJSONFunctions, Geometry, TrigValues } from \"../Geometry\";\r\n\r\n/**\r\n * An `Angle` carries the numeric value of an angle, with methods to allow (require!) callers to\r\n * be clear about whether their angle is degrees or radians.\r\n * * After the Angle object is created, the callers should not know or care whether it is stored in\r\n * `degrees` or `radians` because both are available if requested by caller.\r\n * * The various access method are named so that callers can specify whether untyped numbers passed in or\r\n * out are degrees or radians.\r\n * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/AngleSweep\r\n * @public\r\n */\r\nexport class Angle implements BeJSONFunctions {\r\n /** maximal accuracy value of pi/12 (15 degrees), in radians */\r\n public static readonly piOver12Radians = 0.26179938779914946;\r\n /** maximal accuracy value of pi/4 (45 degrees), in radians */\r\n public static readonly piOver4Radians = 7.853981633974483e-001;\r\n /** maximal accuracy value of pi/2 (90 degrees), in radians */\r\n public static readonly piOver2Radians = 1.5707963267948966e+000;\r\n /** maximal accuracy value of pi (180 degrees), in radians */\r\n public static readonly piRadians = 3.141592653589793e+000;\r\n /** maximal accuracy value of 2*pi (360 degrees), in radians */\r\n public static readonly pi2Radians = 6.283185307179586e+000;\r\n /** scale factor for converting radians to degrees */\r\n public static readonly degreesPerRadian = (45.0 / Angle.piOver4Radians);\r\n /** scale factor for converting degrees to radians */\r\n public static readonly radiansPerDegree = (Angle.piOver4Radians / 45.0);\r\n private _radians: number;\r\n private _degrees?: number;\r\n private constructor(radians = 0, degrees?: number) {\r\n this._radians = radians;\r\n this._degrees = degrees;\r\n }\r\n /** Return a new angle with the same content. */\r\n public clone(): Angle {\r\n return new Angle(this._radians, this._degrees);\r\n }\r\n /** Freeze this instance so it is read-only */\r\n public freeze(): Readonly<this> {\r\n return Object.freeze(this);\r\n }\r\n /**\r\n * Return a new Angle object for angle given in degrees.\r\n * @param degrees angle in degrees\r\n */\r\n public static createDegrees(degrees: number): Angle {\r\n return new Angle(Angle.degreesToRadians(degrees), degrees);\r\n }\r\n /**\r\n * Return a (new) Angle object for a value given in radians.\r\n * @param radians angle in radians\r\n */\r\n public static createRadians(radians: number): Angle {\r\n return new Angle(radians);\r\n }\r\n /**\r\n * Return a new `Angle` object with the default \"small\" angle measurement specified by [[Geometry.smallAngleRadians]].\r\n */\r\n public static createSmallAngle(): Angle {\r\n return new Angle(Geometry.smallAngleRadians);\r\n }\r\n /**\r\n * Return a (new) Angle object that is interpolated between two inputs (based on a fraction)\r\n * @param angle0 first angle in radians\r\n * @param fraction the interpolation fraction\r\n * @param angle1 second angle in radians\r\n */\r\n public static createInterpolate(angle0: Angle, fraction: number, angle1: Angle): Angle {\r\n return new Angle(Geometry.interpolate(angle0.radians, fraction, angle1.radians));\r\n }\r\n /**\r\n * Return a (new) Angle object, with angle scaled from existing angle.\r\n * @param scale scale factor to apply to angle.\r\n */\r\n public cloneScaled(scale: number): Angle {\r\n return new Angle(this.radians * scale);\r\n }\r\n /**\r\n * Set this angle to a value given in radians.\r\n * @param radians angle given in radians\r\n */\r\n public setRadians(radians: number) {\r\n this._radians = radians;\r\n this._degrees = undefined;\r\n }\r\n /**\r\n * Set this angle to a value given in degrees.\r\n * @param degrees angle given in degrees.\r\n */\r\n public setDegrees(degrees: number) {\r\n this._radians = Angle.degreesToRadians(degrees);\r\n this._degrees = degrees;\r\n }\r\n /** Create an angle for a full circle. */\r\n public static create360(): Angle {\r\n return new Angle(Math.PI * 2.0, 360.0);\r\n }\r\n /**\r\n * Create a (strongly typed) Angle whose tangent is `numerator/denominator`, using the signs of both in\r\n * determining the (otherwise ambiguous) quadrant.\r\n * @param numerator numerator for tangent\r\n * @param denominator denominator for tangent\r\n */\r\n public static createAtan2(numerator: number, denominator: number): Angle {\r\n return new Angle(Math.atan2(numerator, denominator));\r\n }\r\n /**\r\n * Copy all contents of `other` to this Angle.\r\n * @param other source data\r\n */\r\n public setFrom(other: Angle) {\r\n this._radians = other._radians;\r\n this._degrees = other._degrees;\r\n }\r\n /**\r\n * Set an Angle from a JSON object\r\n * * A simple number is considered as degrees.\r\n * * specified `json.degrees` or `json._degrees` is degree value.\r\n * * specified `son.radians` or `json._radians` is radians value.\r\n * @param json object from JSON.parse. If a number, value is in *DEGREES*\r\n * @param defaultValRadians if json is undefined, default value in radians.\r\n */\r\n public setFromJSON(json?: AngleProps, defaultValRadians?: number) {\r\n this._radians = defaultValRadians ? defaultValRadians : 0;\r\n if (!json)\r\n return;\r\n if (typeof json === \"number\") {\r\n this.setDegrees(json);\r\n } else if (typeof (json as any).degrees === \"number\") {\r\n this.setDegrees((json as any).degrees);\r\n } else if (typeof (json as any)._degrees === \"number\") {\r\n this.setDegrees((json as any)._degrees);\r\n } else if (typeof (json as any).radians === \"number\") {\r\n this.setRadians((json as any).radians);\r\n } else if (typeof (json as any)._radians === \"number\") {\r\n this.setRadians((json as any)._radians);\r\n }\r\n }\r\n /**\r\n * Create an Angle from a JSON object\r\n * @param json object from JSON.parse. If a number, value is in *DEGREES*\r\n * @param defaultValRadians if json is undefined, default value in radians.\r\n * @return a new Angle\r\n */\r\n public static fromJSON(json?: AngleProps, defaultValRadians?: number): Angle {\r\n const val = new Angle();\r\n val.setFromJSON(json, defaultValRadians);\r\n return val;\r\n }\r\n /** Convert an Angle to a JSON object as a number in degrees */\r\n public toJSON(): AngleProps {\r\n return this.degrees;\r\n }\r\n /** Return a json object with radians keyword, e.g. `{ radians: 0.10}` */\r\n public toJSONRadians(): AngleProps {\r\n return { radians: this.radians };\r\n }\r\n /** Return the angle measured in radians. */\r\n public get radians(): number {\r\n return this._radians;\r\n }\r\n /** Return the angle measured in degrees. */\r\n public get degrees(): number {\r\n return this._degrees !== undefined ? this._degrees : Angle.radiansToDegrees(this._radians);\r\n }\r\n /**\r\n * Convert an angle in degrees to radians.\r\n * @param degrees angle in degrees\r\n */\r\n public static degreesToRadians(degrees: number): number {\r\n return degrees * Math.PI / 180;\r\n }\r\n /**\r\n * Convert an angle in radians to degrees.\r\n * @param degrees angle in radians\r\n */\r\n public static radiansToDegrees(radians: number): number {\r\n if (radians < 0)\r\n return -Angle.radiansToDegrees(-radians);\r\n // Now radians is positive ...\r\n const pi = Math.PI;\r\n const factor = 180.0 / pi;\r\n /* the following if statements are for round-off reasons. The problem is that no IEEE number is\r\n * an exact hit for any primary multiple of pi (90, 180, etc). The following is supposed to have\r\n * a better chance that if the input was computed by direct assignment from 90, 180, etc degrees\r\n * it will return exactly 90,180 etc.\r\n */\r\n if (radians <= 0.25 * pi)\r\n return factor * radians;\r\n if (radians < 0.75 * pi)\r\n return 90.0 + 180 * ((radians - 0.5 * pi) / pi);\r\n if (radians <= 1.25 * pi)\r\n return 180.0 + 180 * ((radians - pi) / pi);\r\n if (radians <= 1.75 * pi)\r\n return 270.0 + 180 * ((radians - 1.5 * pi) / pi);\r\n // all larger radians reference from 360 degrees (2PI)\r\n return 360.0 + 180 * ((radians - 2.0 * pi) / pi);\r\n }\r\n /** Return the cosine of this Angle object's angle */\r\n public cos(): number {\r\n return Math.cos(this._radians);\r\n }\r\n /** Return the sine of this Angle object's angle */\r\n public sin(): number {\r\n return Math.sin(this._radians);\r\n }\r\n /** Return the tangent of this Angle object's angle */\r\n public tan(): number {\r\n return Math.tan(this._radians);\r\n }\r\n /** Test if a radians (absolute) value is nearly 2PI or larger! */\r\n public static isFullCircleRadians(radians: number): boolean {\r\n return Math.abs(radians) >= Geometry.fullCircleRadiansMinusSmallAngle;\r\n }\r\n /** Test if the radians value is a half circle */\r\n public static isHalfCircleRadians(radians: number): boolean {\r\n return Math.abs(Math.abs(radians) - Math.PI) <= Geometry.smallAngleRadians;\r\n }\r\n /** Test if the angle is a full circle */\r\n public get isFullCircle(): boolean {\r\n return Angle.isFullCircleRadians(this._radians);\r\n }\r\n /** Test if the angle is a half circle (in either direction) */\r\n public get isHalfCircle(): boolean {\r\n return Angle.isHalfCircleRadians(this._radians);\r\n }\r\n /** Adjust a radians value so it is positive in 0..360 */\r\n public static adjustDegrees0To360(degrees: number): number {\r\n if (degrees >= 0) {\r\n const period = 360.0;\r\n if (degrees < period)\r\n return degrees;\r\n const numPeriods = Math.floor(degrees / period);\r\n return degrees - numPeriods * period;\r\n } else if (degrees < 0) {\r\n // negative angle ...\r\n const radians = Angle.adjustDegrees0To360(-degrees);\r\n return 360.0 - radians;\r\n }\r\n // fall through for Nan (disaster) !!!\r\n return 0;\r\n }\r\n /** Adjust a radians value so it is in -180..180 */\r\n public static adjustDegreesSigned180(degrees: number): number {\r\n if (Math.abs(degrees) <= 180.0)\r\n return degrees;\r\n if (degrees >= 0) {\r\n const period = 360.0;\r\n const numPeriods = 1 + Math.floor((degrees - 180.0) / period);\r\n return degrees - numPeriods * period;\r\n } else if (degrees < 0) {\r\n // negative angle ...\r\n return -Angle.adjustDegreesSigned180(-degrees);\r\n }\r\n // fall through for NaN disaster.\r\n return 0;\r\n }\r\n /** Adjust a radians value so it is positive in 0..2Pi */\r\n public static adjustRadians0To2Pi(radians: number): number {\r\n if (radians >= 0) {\r\n const period = Math.PI * 2.0;\r\n if (radians < period)\r\n return radians;\r\n const numPeriods = Math.floor(radians / period);\r\n return radians - numPeriods * period;\r\n } else if (radians < 0) {\r\n // negative angle ...\r\n return Math.PI * 2.0 - Angle.adjustRadians0To2Pi(-radians);\r\n }\r\n // fall through for NaN disaster.\r\n return 0;\r\n }\r\n /** Adjust a radians value so it is positive in -PI..PI */\r\n public static adjustRadiansMinusPiPlusPi(radians: number): number {\r\n if (Math.abs(radians) <= Math.PI)\r\n return radians;\r\n if (radians >= 0) {\r\n const period = Math.PI * 2.0;\r\n const numPeriods = 1 + Math.floor((radians - Math.PI) / period);\r\n return radians - numPeriods * period;\r\n } else if (radians < 0) {\r\n // negative angle ...\r\n return -Angle.adjustRadiansMinusPiPlusPi(-radians);\r\n }\r\n // fall through for NaN disaster.\r\n return 0;\r\n }\r\n /** Return a (newly allocated) Angle object with value 0 radians */\r\n public static zero(): Angle {\r\n return new Angle(0);\r\n }\r\n /** Test if the angle is exactly zero. */\r\n public get isExactZero(): boolean {\r\n return this.radians === 0;\r\n }\r\n /** Test if the angle is almost zero (within tolerance `Geometry.smallAngleRadians`) */\r\n public get isAlmostZero(): boolean {\r\n return Math.abs(this.radians) < Geometry.smallAngleRadians;\r\n }\r\n /** Test if the angle is almost a north or south pole (within tolerance `Geometry.smallAngleRadians`) */\r\n public get isAlmostNorthOrSouthPole(): boolean {\r\n return Angle.isHalfCircleRadians(this.radians * 2.0);\r\n }\r\n /** Create an angle object with degrees adjusted into 0..360. */\r\n public static createDegreesAdjustPositive(degrees: number): Angle {\r\n return Angle.createDegrees(Angle.adjustDegrees0To360(degrees));\r\n }\r\n /** Create an angle object with degrees adjusted into -180..180. */\r\n public static createDegreesAdjustSigned180(degrees: number): Angle {\r\n return Angle.createDegrees(Angle.adjustDegreesSigned180(degrees));\r\n }\r\n /**\r\n * Test if two radians values are equivalent, allowing shift by full circle (i.e. by a multiple of `2*PI`)\r\n * @param radiansA first radians value\r\n * @param radiansB second radians value\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public static isAlmostEqualRadiansAllowPeriodShift(radiansA: number, radiansB: number,\r\n radianTol: number = Geometry.smallAngleRadians): boolean {\r\n const delta = Math.abs(radiansA - radiansB);\r\n if (delta <= radianTol)\r\n return true;\r\n const period = Math.PI * 2.0;\r\n if (Math.abs(delta - period) <= radianTol)\r\n return true;\r\n const numPeriod = Math.round(delta / period);\r\n const delta1 = delta - numPeriod * period;\r\n return Math.abs(delta1) <= radianTol;\r\n }\r\n /**\r\n * Test if this angle has magnitude no greater than that of `other`.\r\n * @param other the other angle\r\n */\r\n public isMagnitudeLessThanOrEqual(other: Angle): boolean {\r\n return Math.abs(this.radians) <= Math.abs(other.radians);\r\n }\r\n\r\n /**\r\n * Test if this angle and other are equivalent, allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * @param other the other angle\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public isAlmostEqualAllowPeriodShift(other: Angle, radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return Angle.isAlmostEqualRadiansAllowPeriodShift(this._radians, other._radians, radianTol);\r\n }\r\n /**\r\n * Test if two angle (in radians) almost equal, NOT allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * @param radiansA first radians value\r\n * @param radiansB second radians value\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public static isAlmostEqualRadiansNoPeriodShift(radiansA: number, radiansB: number,\r\n radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return Math.abs(radiansA - radiansB) < radianTol;\r\n }\r\n /**\r\n * Test if two this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * @param other the other angle\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public isAlmostEqualNoPeriodShift(other: Angle, radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return Angle.isAlmostEqualRadiansNoPeriodShift(this._radians, other._radians, radianTol);\r\n }\r\n /**\r\n * Test if two this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of `2 * PI`).\r\n * * This function is same as isAlmostEqualRadiansNoPeriodShift. Please use isAlmostEqualRadiansNoPeriodShift.\r\n * @param other the other angle\r\n * @param radianTol radian tolerance with default value of Geometry.smallAngleRadians\r\n */\r\n public isAlmostEqual(other: Angle, radianTol: number = Geometry.smallAngleRadians): boolean {\r\n return this.isAlmostEqualNoPeriodShift(other, radianTol);\r\n }\r\n /**\r\n * Test if dot product values indicate non-zero length perpendicular vectors.\r\n * @param dotUU dot product of vectorU with itself\r\n * @param dotVV dot product of vectorV with itself\r\n * @param dotUV dot product of vectorU with vectorV\r\n */\r\n public static isPerpendicularDotSet(dotUU: number, dotVV: number, dotUV: number): boolean {\r\n return dotUU > Geometry.smallMetricDistanceSquared\r\n && dotVV > Geometry.smallMetricDistanceSquared\r\n && dotUV * dotUV <= Geometry.smallAngleRadiansSquared * dotUU * dotVV;\r\n }\r\n /**\r\n * Compute the angle A given r*cos(2A) and r*sin(2A) for some nonnegative scalar r.\r\n * * This function assumes the input arguments are related to an angle between -PI and PI.\r\n * * This function returns an angle between -PI and PI.\r\n * @param rCos2A scaled cosine value of twice the angle A.\r\n * @param rSin2A scaled sine value of twice the angle A.\r\n * @return cos(A), sin(A) and A in radians\r\n */\r\n public static trigValuesToHalfAngleTrigValues(rCos2A: number, rSin2A: number): TrigValues {\r\n const r = Geometry.hypotenuseXY(rCos2A, rSin2A);\r\n if (r < Geometry.smallMetricDistance) {\r\n return { c: 1.0, s: 0.0, radians: 0.0 }; // angle = 0\r\n } else {\r\n /* If the caller really gave you sine and cosine values, r should be 1. However,\r\n * to allow scaled values -- e.g. the x and y components of any vector -- we normalize\r\n * right here. This adds an extra sqrt and two divisions, but improves\r\n * both the usefulness and robustness of the computation.\r\n */\r\n let cosA;\r\n let sinA = 0.0;\r\n const cos2A = rCos2A / r;\r\n const sin2A = rSin2A / r;\r\n if (cos2A >= 0.0) { // 2A is in NE and SE quadrants, A in same quadrant\r\n cosA = Math.sqrt(0.5 * (1.0 + cos2A)); // half angle formula. Use +root since cosA >= 0\r\n sinA = sin2A / (2.0 * cosA); // double angle formula\r\n } else {\r\n if (sin2A > 0.0) { // 2A in NW quadrant. A in NE quadrant\r\n sinA = Math.sqrt(0.5 * (1.0 - cos2A)); // half angle formula. Use +root since sinA > 0\r\n } else { // 2A in SW quadrant. A in SE quadrant\r\n sinA = -Math.sqrt(0.5 * (1.0 - cos2A)); // half angle formula. Use -root since sinA <= 0\r\n }\r\n cosA = sin2A / (2.0 * sinA); // double angle formula\r\n }\r\n return { c: cosA, s: sinA, radians: Math.atan2(sinA, cosA) };\r\n }\r\n }\r\n /** If value is close to -1, -0.5, 0, 0.5, 1, adjust it to the exact value. */\r\n public static cleanupTrigValue(value: number, tolerance: number = Geometry.smallFloatingPoint): number {\r\n const absValue = Math.abs(value);\r\n if (absValue <= tolerance)\r\n return 0;\r\n let a = Math.abs(absValue - 0.5);\r\n if (a <= tolerance)\r\n return value < 0.0 ? -0.5 : 0.5;\r\n a = Math.abs(absValue - 1.0);\r\n if (a <= tolerance)\r\n return value < 0.0 ? -1.0 : 1.0;\r\n return value;\r\n }\r\n /**\r\n * Return the half angle cosine, sine, and radians for the given vector dot products.\r\n * * These values arise e.g. in the computation performed in `Arc3d.toScaledMatrix3d`.\r\n * * Let vectors U and V define the ellipse x(t) = c + U cos(t) + V sin(t). We seek an angle t0\r\n * such that the radial vector W(t0) := x(t0) - c is perpendicular to the ellipse.\r\n * * Then 0 = W(t0).x'(t0) = (U cos(t0) + V sin(t0)).(V cos(t0) - U sin(t0)) = U.V cos(2t0) + 0.5 (V.V - U.U) sin(2t0)\r\n * implies tan(2t0) = sin(2t0) / cos(2t0) = 2 U.V / (U.U - V.V), i.e., t0 can be computed given the input dot products.\r\n * Math details can be found at docs/learning/geometry/Angle.md\r\n * @param dotUU dot product of vectorU with itself\r\n * @param dotVV dot product of vectorV with itself\r\n * @param dotUV dot product of vectorU with vectorV\r\n * @param favorZero whether to allow a tight tolerance for returning t0 = 0 (default true).\r\n * When dotUV is near zero, U and V are nearly perpendicular, and the returned angle is near zero.\r\n * @return the angle t0 and its cosine and sine.\r\n */\r\n public static dotProductsToHalfAngleTrigValues(\r\n dotUU: number, dotVV: number, dotUV: number, favorZero: boolean = true,\r\n ): TrigValues {\r\n const cos2t0 = dotUU - dotVV;\r\n const sin2t0 = 2.0 * dotUV;\r\n if (favorZero && Math.abs(sin2t0) < Geometry.smallAngleRadians * (Math.abs(dotUU) + Math.abs(dotVV)))\r\n return { c: 1.0, s: 0.0, radians: 0.0 };\r\n return Angle.trigValuesToHalfAngleTrigValues(cos2t0, sin2t0);\r\n }\r\n /**\r\n * Returns the angle between two vectors, with the vectors given as xyz components\r\n * * The returned angle is between 0 and PI\r\n * @param ux x component of vector u\r\n * @param uy y component of vector u\r\n * @param uz z component of vector u\r\n * @param vx x component of vector v\r\n * @param vy y component of vector v\r\n * @param vz z component of vector v\r\n */\r\n public static radiansBetweenVectorsXYZ(\r\n ux: number, uy: number, uz: number, vx: number, vy: number, vz: number,\r\n ): number {\r\n const uDotV = ux * vx + uy * vy + uz * vz;\r\n return Math.atan2(Geometry.crossProductMagnitude(ux, uy, uz, vx, vy, vz), uDotV);\r\n }\r\n /**\r\n * Returns the angle between two vectors, with the vectors given as xyz components, and an up vector to resolve\r\n * angle to a full 2PI range.\r\n * * The returned angle is (-PI < radians <= PI) or (0 <= radians < 2 * PI)\r\n * * The angle is in the plane of the U and V vectors.\r\n * * The upVector determines a positive side of the plane but need not be strictly perpendicular to the plane.\r\n * @param ux x component of vector u\r\n * @param uy y component of vector u\r\n * @param uz z component of vector u\r\n * @param vx x component of vector v\r\n * @param vy y component of vector v\r\n * @param vz z component of vector v\r\n * @param upVectorX x component of vector to positive side of plane.\r\n * @param upVectorY y component of vector to positive side of plane.\r\n * @param upVectorZ z component of vector to positive side of plane.\r\n * @param adjustToAllPositive if true, return strictly non-negative sweep (0 <= radians < 2*PI). If false, return\r\n * signed (-PI < radians <= PI)\r\n */\r\n public static orientedRadiansBetweenVectorsXYZ(\r\n ux: number, uy: number, uz: number,\r\n vx: number, vy: number, vz: number,\r\n upVectorX: number, upVectorY: number, upVectorZ: number,\r\n adjustToPositive: boolean = false,\r\n ): number {\r\n const uDotV = ux * vx + uy * vy + uz * vz;\r\n const wx = uy * vz - uz * vy;\r\n const wy = uz * vx - ux * vz;\r\n const wz = ux * vy - uy * vx;\r\n const upDotW = upVectorX * wx + upVectorY * wy + upVectorZ * wz;\r\n const crossMagnitude = Geometry.hypotenuseXYZ(wx, wy, wz);\r\n if (upDotW < 0.0) {\r\n if (adjustToPositive) {\r\n // The turn is greater than 180 degrees. Take a peculiarly oriented atan2 to get the excess-180 part as\r\n // addition to PI. This gives the smoothest numerical transition passing PI.\r\n return Math.PI + Math.atan2(crossMagnitude, -uDotV);\r\n } else {\r\n return -Math.atan2(crossMagnitude, uDotV);\r\n }\r\n } else {\r\n return Math.atan2(crossMagnitude, uDotV);\r\n }\r\n }\r\n /**\r\n * Add a multiple of a full circle angle (360 degrees, 2PI) in place.\r\n * @param multiple multiplier factor\r\n */\r\n public addMultipleOf2PiInPlace(multiple: number) {\r\n if (this._degrees !== undefined) {\r\n this._degrees += multiple * 360.0;\r\n this._radians = Angle.degreesToRadians(this._degrees);\r\n } else {\r\n this._radians += multiple * Angle.pi2Radians;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Angle } from "../geometry3d/Angle";
|
|
1
2
|
import { Point2d } from "../geometry3d/Point2dVector2d";
|
|
2
|
-
import {
|
|
3
|
+
import { Vector3d } from "../geometry3d/Point3dVector3d";
|
|
4
|
+
import { IndexedPolyface, PolyfaceVisitor } from "./Polyface";
|
|
3
5
|
import { PolyfaceData } from "./PolyfaceData";
|
|
4
6
|
/**
|
|
5
7
|
* An `IndexedPolyfaceVisitor` is an iterator-like object that "visits" facets of a mesh.
|
|
@@ -14,7 +16,9 @@ export declare class IndexedPolyfaceVisitor extends PolyfaceData implements Poly
|
|
|
14
16
|
private _polyface;
|
|
15
17
|
protected constructor(polyface: IndexedPolyface, numWrap: number);
|
|
16
18
|
/** Return the client polyface object. */
|
|
17
|
-
clientPolyface():
|
|
19
|
+
clientPolyface(): IndexedPolyface;
|
|
20
|
+
/** Return the number of facets this visitor is able to visit. */
|
|
21
|
+
getVisitableFacetCount(): number;
|
|
18
22
|
/**
|
|
19
23
|
* Set the number of vertices replicated in visitor arrays (both data and index arrays).
|
|
20
24
|
* * 0,1,2 are the most common as numWrap.
|
|
@@ -73,27 +77,56 @@ export declare class IndexedPolyfaceVisitor extends PolyfaceData implements Poly
|
|
|
73
77
|
/**
|
|
74
78
|
* An `IndexedPolyfaceSubsetVisitor` is an `IndexedPolyfaceVisitor` which only visits a subset of facets in the polyface.
|
|
75
79
|
* * The subset is defined by an array of facet indices provided when this visitor is created.
|
|
76
|
-
* *
|
|
77
|
-
* * `moveToNextFacet` moves only within the subset.
|
|
78
|
-
* * `moveToReadIndex(i)` moves underlying visitor's `parentFacetIndex(i)`.
|
|
80
|
+
* * Input indices (e.g., for `moveToReadIndex`) are understood to be indices into the subset array.
|
|
79
81
|
* @public
|
|
80
82
|
*/
|
|
81
83
|
export declare class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {
|
|
82
|
-
private _parentFacetIndices
|
|
84
|
+
private _parentFacetIndices?;
|
|
85
|
+
private _currentActiveIndex;
|
|
83
86
|
private _nextActiveIndex;
|
|
84
87
|
private constructor();
|
|
88
|
+
private isValidSubsetIndex;
|
|
85
89
|
/**
|
|
86
90
|
* Create a visitor for iterating a subset of the facets of `polyface`.
|
|
87
|
-
*
|
|
91
|
+
* @param polyface reference to the client polyface, supplying facets
|
|
92
|
+
* @param activeFacetIndices array of indices of facets in the client polyface to visit. This array is cloned.
|
|
93
|
+
* @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.
|
|
94
|
+
*/
|
|
95
|
+
static createSubsetVisitor(polyface: IndexedPolyface, activeFacetIndices: number[], numWrap?: number): IndexedPolyfaceSubsetVisitor;
|
|
96
|
+
/**
|
|
97
|
+
* Advance the iterator to a particular facet in the subset of client polyface facets.
|
|
98
|
+
* @param activeIndex the index of the facet within the subset, not to be confused with the index of the facet within the client polyface.
|
|
99
|
+
* @return whether the iterator was successfully moved.
|
|
88
100
|
*/
|
|
89
|
-
static createSubsetVisitor(polyface: IndexedPolyface, activeFacetIndices: number[], numWrap: number): IndexedPolyfaceSubsetVisitor;
|
|
90
|
-
/** Advance the iterator to a particular facet in the client polyface. */
|
|
91
101
|
moveToReadIndex(activeIndex: number): boolean;
|
|
92
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Advance the iterator to the next facet in the subset of client polyface facets.
|
|
104
|
+
* @return whether the iterator was successfully moved.
|
|
105
|
+
*/
|
|
93
106
|
moveToNextFacet(): boolean;
|
|
94
|
-
/** Reset the iterator to start at the first active facet in the polyface. */
|
|
107
|
+
/** Reset the iterator to start at the first active facet in the subset of client polyface facets. */
|
|
95
108
|
reset(): void;
|
|
96
|
-
/**
|
|
97
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Return the parent facet index of the indicated index within the subset of client polyface facets.
|
|
111
|
+
* @param activeIndex index of the facet within the subset. Default is the active facet.
|
|
112
|
+
* @return valid client polyface facet index, or `undefined` if invalid input index.
|
|
113
|
+
*/
|
|
114
|
+
parentFacetIndex(activeIndex?: number): number | undefined;
|
|
115
|
+
/** Return the number of facets this visitor is able to visit. */
|
|
116
|
+
getVisitableFacetCount(): number;
|
|
117
|
+
/**
|
|
118
|
+
* Create a visitor for those mesh facets with normal in the same half-space as the given vector.
|
|
119
|
+
* * For example, to visit the top facets of a tiled terrain mesh but skip the "skirt" facets, pass
|
|
120
|
+
* `compareVector = Vector3d.unitZ()` and a suitable `sideAngle` tolerance. Note that this will also
|
|
121
|
+
* filter out *interior* facets that are nearly vertical, not just the "skirt" facets on the boundary.
|
|
122
|
+
* @param mesh the mesh from which to select facets
|
|
123
|
+
* @param compareVector vector to which to compare facet normals. The visitor will visit only those facets
|
|
124
|
+
* with normals in the same half-space as this vector. Default is 001.
|
|
125
|
+
* @param sideAngle optional angular tolerance to filter the facets near the border between half-spaces.
|
|
126
|
+
* The visitor will *not* visit facets whose normals are nearly perpendicular to `compareVector`.
|
|
127
|
+
* Default is [[Geometry.smallAngleRadians]].
|
|
128
|
+
* @param numWrap optional number of entries replicated in visitor arrays. Default is 0.
|
|
129
|
+
*/
|
|
130
|
+
static createNormalComparison(mesh: IndexedPolyface | IndexedPolyfaceVisitor, compareVector?: Vector3d, sideAngle?: Angle, numWrap?: number): IndexedPolyfaceSubsetVisitor;
|
|
98
131
|
}
|
|
99
132
|
//# sourceMappingURL=IndexedPolyfaceVisitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedPolyfaceVisitor.d.ts","sourceRoot":"","sources":["../../../src/polyface/Ind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,OAAO;IAM1C,qGAAqG;IACrF,KAAK,IAAI,IAAI;IAI7B;;;;OAIG;IACI,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKjE,iEAAiE;IACjD,sBAAsB,IAAI,MAAM;IAGhD;;;;;;;;;;;;MAYE;WACY,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,sBAAsB,EAAE,aAAa,GAAE,QAA2B,EAAE,SAAS,GAAE,KAAgC,EAAE,OAAO,GAAE,MAAU,GAAG,4BAA4B;CAiBjO"}
|
|
@@ -9,6 +9,10 @@ exports.IndexedPolyfaceSubsetVisitor = exports.IndexedPolyfaceVisitor = void 0;
|
|
|
9
9
|
* @module Polyface
|
|
10
10
|
*/
|
|
11
11
|
const Geometry_1 = require("../Geometry");
|
|
12
|
+
const Angle_1 = require("../geometry3d/Angle");
|
|
13
|
+
const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
|
|
14
|
+
const PolygonOps_1 = require("../geometry3d/PolygonOps");
|
|
15
|
+
const Polyface_1 = require("./Polyface");
|
|
12
16
|
const PolyfaceData_1 = require("./PolyfaceData");
|
|
13
17
|
/* eslint-disable @itwin/prefer-get */
|
|
14
18
|
/**
|
|
@@ -33,6 +37,10 @@ class IndexedPolyfaceVisitor extends PolyfaceData_1.PolyfaceData {
|
|
|
33
37
|
clientPolyface() {
|
|
34
38
|
return this._polyface;
|
|
35
39
|
}
|
|
40
|
+
/** Return the number of facets this visitor is able to visit. */
|
|
41
|
+
getVisitableFacetCount() {
|
|
42
|
+
return this._polyface.facetCount;
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* Set the number of vertices replicated in visitor arrays (both data and index arrays).
|
|
38
46
|
* * 0,1,2 are the most common as numWrap.
|
|
@@ -178,53 +186,99 @@ exports.IndexedPolyfaceVisitor = IndexedPolyfaceVisitor;
|
|
|
178
186
|
/**
|
|
179
187
|
* An `IndexedPolyfaceSubsetVisitor` is an `IndexedPolyfaceVisitor` which only visits a subset of facets in the polyface.
|
|
180
188
|
* * The subset is defined by an array of facet indices provided when this visitor is created.
|
|
181
|
-
* *
|
|
182
|
-
* * `moveToNextFacet` moves only within the subset.
|
|
183
|
-
* * `moveToReadIndex(i)` moves underlying visitor's `parentFacetIndex(i)`.
|
|
189
|
+
* * Input indices (e.g., for `moveToReadIndex`) are understood to be indices into the subset array.
|
|
184
190
|
* @public
|
|
185
191
|
*/
|
|
186
192
|
class IndexedPolyfaceSubsetVisitor extends IndexedPolyfaceVisitor {
|
|
187
193
|
constructor(polyface, activeFacetIndices, numWrap) {
|
|
188
194
|
super(polyface, numWrap);
|
|
189
195
|
this._parentFacetIndices = activeFacetIndices.slice();
|
|
196
|
+
this._currentActiveIndex = -1;
|
|
190
197
|
this._nextActiveIndex = 0;
|
|
191
198
|
}
|
|
199
|
+
isValidSubsetIndex(index) {
|
|
200
|
+
return (undefined !== this._parentFacetIndices) && index >= 0 && index < this._parentFacetIndices.length;
|
|
201
|
+
}
|
|
192
202
|
/**
|
|
193
203
|
* Create a visitor for iterating a subset of the facets of `polyface`.
|
|
194
|
-
*
|
|
204
|
+
* @param polyface reference to the client polyface, supplying facets
|
|
205
|
+
* @param activeFacetIndices array of indices of facets in the client polyface to visit. This array is cloned.
|
|
206
|
+
* @param numWrap number of vertices replicated in the visitor arrays to facilitate simpler caller code. Default is zero.
|
|
195
207
|
*/
|
|
196
|
-
static createSubsetVisitor(polyface, activeFacetIndices, numWrap) {
|
|
208
|
+
static createSubsetVisitor(polyface, activeFacetIndices, numWrap = 0) {
|
|
197
209
|
return new IndexedPolyfaceSubsetVisitor(polyface, activeFacetIndices, numWrap);
|
|
198
210
|
}
|
|
199
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* Advance the iterator to a particular facet in the subset of client polyface facets.
|
|
213
|
+
* @param activeIndex the index of the facet within the subset, not to be confused with the index of the facet within the client polyface.
|
|
214
|
+
* @return whether the iterator was successfully moved.
|
|
215
|
+
*/
|
|
200
216
|
moveToReadIndex(activeIndex) {
|
|
201
|
-
if (
|
|
202
|
-
this.
|
|
203
|
-
|
|
217
|
+
if (this.isValidSubsetIndex(activeIndex)) {
|
|
218
|
+
this._currentActiveIndex = activeIndex;
|
|
219
|
+
this._nextActiveIndex = activeIndex + 1;
|
|
220
|
+
return super.moveToReadIndex(this._parentFacetIndices[activeIndex]);
|
|
204
221
|
}
|
|
205
222
|
return false;
|
|
206
223
|
}
|
|
207
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Advance the iterator to the next facet in the subset of client polyface facets.
|
|
226
|
+
* @return whether the iterator was successfully moved.
|
|
227
|
+
*/
|
|
208
228
|
moveToNextFacet() {
|
|
209
|
-
if (this._nextActiveIndex
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return true;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return false;
|
|
229
|
+
if (this._nextActiveIndex !== this._currentActiveIndex)
|
|
230
|
+
return this.moveToReadIndex(this._nextActiveIndex);
|
|
231
|
+
this._nextActiveIndex++;
|
|
232
|
+
return true;
|
|
217
233
|
}
|
|
218
|
-
/** Reset the iterator to start at the first active facet in the polyface. */
|
|
234
|
+
/** Reset the iterator to start at the first active facet in the subset of client polyface facets. */
|
|
219
235
|
reset() {
|
|
220
|
-
this.
|
|
236
|
+
this.moveToReadIndex(0);
|
|
237
|
+
this._nextActiveIndex = 0; // so immediate moveToNextFacet stays here.
|
|
221
238
|
}
|
|
222
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* Return the parent facet index of the indicated index within the subset of client polyface facets.
|
|
241
|
+
* @param activeIndex index of the facet within the subset. Default is the active facet.
|
|
242
|
+
* @return valid client polyface facet index, or `undefined` if invalid input index.
|
|
243
|
+
*/
|
|
223
244
|
parentFacetIndex(activeIndex) {
|
|
224
|
-
if (
|
|
225
|
-
|
|
245
|
+
if (undefined === activeIndex)
|
|
246
|
+
activeIndex = this._currentActiveIndex;
|
|
247
|
+
return this.isValidSubsetIndex(activeIndex) ? this._parentFacetIndices[activeIndex] : undefined;
|
|
248
|
+
}
|
|
249
|
+
/** Return the number of facets this visitor is able to visit. */
|
|
250
|
+
getVisitableFacetCount() {
|
|
251
|
+
return this._parentFacetIndices ? this._parentFacetIndices.length : 0;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create a visitor for those mesh facets with normal in the same half-space as the given vector.
|
|
255
|
+
* * For example, to visit the top facets of a tiled terrain mesh but skip the "skirt" facets, pass
|
|
256
|
+
* `compareVector = Vector3d.unitZ()` and a suitable `sideAngle` tolerance. Note that this will also
|
|
257
|
+
* filter out *interior* facets that are nearly vertical, not just the "skirt" facets on the boundary.
|
|
258
|
+
* @param mesh the mesh from which to select facets
|
|
259
|
+
* @param compareVector vector to which to compare facet normals. The visitor will visit only those facets
|
|
260
|
+
* with normals in the same half-space as this vector. Default is 001.
|
|
261
|
+
* @param sideAngle optional angular tolerance to filter the facets near the border between half-spaces.
|
|
262
|
+
* The visitor will *not* visit facets whose normals are nearly perpendicular to `compareVector`.
|
|
263
|
+
* Default is [[Geometry.smallAngleRadians]].
|
|
264
|
+
* @param numWrap optional number of entries replicated in visitor arrays. Default is 0.
|
|
265
|
+
*/
|
|
266
|
+
static createNormalComparison(mesh, compareVector = Point3dVector3d_1.Vector3d.unitZ(), sideAngle = Angle_1.Angle.createSmallAngle(), numWrap = 0) {
|
|
267
|
+
if (mesh instanceof Polyface_1.IndexedPolyface)
|
|
268
|
+
return this.createNormalComparison(mesh.createVisitor(), compareVector, sideAngle, numWrap);
|
|
269
|
+
const visitor = mesh;
|
|
270
|
+
const facets = [];
|
|
271
|
+
const facetNormal = Point3dVector3d_1.Vector3d.createZero();
|
|
272
|
+
for (visitor.reset(); visitor.moveToNextFacet();) {
|
|
273
|
+
if (!PolygonOps_1.PolygonOps.unitNormal(visitor.point, facetNormal))
|
|
274
|
+
continue; // degenerate facet
|
|
275
|
+
if (facetNormal.dotProduct(compareVector) < 0.0)
|
|
276
|
+
continue; // ignore facet facing other half-space
|
|
277
|
+
if (facetNormal.angleFromPerpendicular(compareVector).isMagnitudeLessThanOrEqual(sideAngle))
|
|
278
|
+
continue; // ignore side facet
|
|
279
|
+
facets.push(visitor.currentReadIndex());
|
|
226
280
|
}
|
|
227
|
-
return
|
|
281
|
+
return IndexedPolyfaceSubsetVisitor.createSubsetVisitor(visitor.clientPolyface(), facets, numWrap);
|
|
228
282
|
}
|
|
229
283
|
}
|
|
230
284
|
exports.IndexedPolyfaceSubsetVisitor = IndexedPolyfaceSubsetVisitor;
|