@itwin/core-geometry 5.0.0-dev.82 → 5.0.0-dev.84
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/lib/cjs/Geometry.d.ts +2 -4
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +2 -4
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -4
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +4 -4
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +1 -1
- package/lib/cjs/geometry3d/Transform.js +1 -1
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +54 -41
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +83 -69
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/solid/Cone.d.ts +39 -14
- package/lib/cjs/solid/Cone.d.ts.map +1 -1
- package/lib/cjs/solid/Cone.js +50 -18
- package/lib/cjs/solid/Cone.js.map +1 -1
- package/lib/cjs/solid/Sphere.d.ts +34 -17
- package/lib/cjs/solid/Sphere.d.ts.map +1 -1
- package/lib/cjs/solid/Sphere.js +47 -22
- package/lib/cjs/solid/Sphere.js.map +1 -1
- package/lib/esm/Geometry.d.ts +2 -4
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +2 -4
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +1 -1
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -4
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +4 -4
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +1 -1
- package/lib/esm/geometry3d/Transform.js +1 -1
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +54 -41
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +83 -69
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/solid/Cone.d.ts +39 -14
- package/lib/esm/solid/Cone.d.ts.map +1 -1
- package/lib/esm/solid/Cone.js +51 -19
- package/lib/esm/solid/Cone.js.map +1 -1
- package/lib/esm/solid/Sphere.d.ts +34 -17
- package/lib/esm/solid/Sphere.d.ts.map +1 -1
- package/lib/esm/solid/Sphere.js +48 -23
- package/lib/esm/solid/Sphere.js.map +1 -1
- package/package.json +3 -3
package/lib/cjs/solid/Cone.d.ts
CHANGED
|
@@ -10,20 +10,31 @@ import { Range3d } from "../geometry3d/Range";
|
|
|
10
10
|
import { Transform } from "../geometry3d/Transform";
|
|
11
11
|
import { SolidPrimitive } from "./SolidPrimitive";
|
|
12
12
|
/**
|
|
13
|
-
* A cone with axis along the z
|
|
14
|
-
*
|
|
15
|
-
* *
|
|
16
|
-
* * Either
|
|
17
|
-
* *
|
|
13
|
+
* A cone with axis along the z-axis of a (possibly skewed) local coordinate system.
|
|
14
|
+
* * The curved surface of the cone `C` with axis `vectorZ = centerB - centerA` is parameterized over (u,v) in [0,1]x[0,1] by
|
|
15
|
+
* `C(u,v) = centerA + vFractionToRadius(v) * (cos(u * 2pi) * vectorX + sin(u * 2pi) * vectorY) + v * vectorZ`.
|
|
16
|
+
* * Either radius may be zero, but they may not both be zero.
|
|
17
|
+
* * Cross section size is determined by the lengths of `vectorX`, `vectorY`, and the radii.
|
|
18
|
+
* * If `vectorX` and `vectorY` are orthonormal, the cross sections are circular, with sections at v = 0 and v = 1 having radius
|
|
19
|
+
* `radiusA` and `radiusB`, respectively; otherwise, the cross sections are elliptical.
|
|
20
|
+
* * The stored matrix encapsulates `vectorX`, `vectorY`, and `vectorZ` in the respective columns. Typically the first two columns
|
|
21
|
+
* are orthogonal and unit length, and the last is full length.
|
|
22
|
+
* * Creating a Cone without orthogonal xy-axes of equal length is possible, but not recommended, for the resulting geometry
|
|
23
|
+
* lacks portability; for example, such a Cone cannot be represented as a DGN element (see [[createDgnCone]]).
|
|
18
24
|
* @public
|
|
19
25
|
*/
|
|
20
26
|
export declare class Cone extends SolidPrimitive implements UVSurface, UVSurfaceIsoParametricDistance {
|
|
21
27
|
/** String name for schema properties */
|
|
22
28
|
readonly solidPrimitiveType = "cone";
|
|
29
|
+
/** Local to world transform. Axes may have any nonzero length and may be non-perpendicular. */
|
|
23
30
|
private _localToWorld;
|
|
31
|
+
/** Nominal cross sectional radius at z=0 (scales the cone's xy-axes). */
|
|
24
32
|
private _radiusA;
|
|
33
|
+
/** Nominal cross sectional radius at z=1 (scales the cone's xy-axes). */
|
|
25
34
|
private _radiusB;
|
|
35
|
+
/** Maximum of _radiusA and _radiusB. */
|
|
26
36
|
private _maxRadius;
|
|
37
|
+
/** Constructor, inputs CONSUMED. */
|
|
27
38
|
protected constructor(map: Transform, radiusA: number, radiusB: number, capped: boolean);
|
|
28
39
|
/** Return a clone of this Cone. */
|
|
29
40
|
clone(): Cone;
|
|
@@ -43,16 +54,30 @@ export declare class Cone extends SolidPrimitive implements UVSurface, UVSurface
|
|
|
43
54
|
* * This fails if the transformation is singular.
|
|
44
55
|
*/
|
|
45
56
|
cloneTransformed(transform: Transform): Cone | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* from
|
|
48
|
-
* *
|
|
49
|
-
* *
|
|
57
|
+
/**
|
|
58
|
+
* Create a right circular cylinder or cone from the given base centers and radii.
|
|
59
|
+
* * The circular cross sections are perpendicular to the axis line between the centers.
|
|
60
|
+
* * Both radii must be of the same sign, and at least one radius must be nonzero.
|
|
61
|
+
* * Negative radii are accepted to create an interior surface, however the downstream effects of this, combined with capping, may be problematic.
|
|
62
|
+
*/
|
|
63
|
+
static createAxisPoints(centerA: Point3d, centerB: Point3d, radiusA: number, radiusB: number, capped?: boolean): Cone | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Create a general cone from cross sections parallel to the plane spanned by the given vectors.
|
|
66
|
+
* * Circular cross sections are indicated by perpendicular vectors of the same length.
|
|
67
|
+
* * Elliptical cross sections are indicated by non-perpendicular vectors, or vectors of different lengths.
|
|
68
|
+
* * Cross sectional planes do not have to be perpendicular to the axis line between centers.
|
|
69
|
+
* * Cross section size is affected both by the given vector lengths and radii. To avoid unexpected scaling,
|
|
70
|
+
* pass orthonormal vectors for circular cross sections, or unit radii for elliptical cross sections.
|
|
71
|
+
* * There is no validation of the input radii. For best results, they should be nonnegative, and at least one should be nonzero.
|
|
50
72
|
*/
|
|
51
|
-
static
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
73
|
+
static createBaseAndTarget(centerA: Point3d, centerB: Point3d, vectorX: Vector3d, vectorY: Vector3d, radiusA: number, radiusB: number, capped?: boolean): Cone;
|
|
74
|
+
/**
|
|
75
|
+
* Create a circular cone from the typical parameters of the DGN file.
|
|
76
|
+
* * This method calls [[createBaseAndTarget]] with normalized vectors, `vectorY` squared against `vectorX`, and
|
|
77
|
+
* `radiusA` and `radiusB` scaled by the original length of `vectorX`.
|
|
78
|
+
* * These restrictions allow the cone to be represented by an element in the DGN file.
|
|
54
79
|
*/
|
|
55
|
-
static
|
|
80
|
+
static createDgnCone(centerA: Point3d, centerB: Point3d, vectorX: Vector3d, vectorY: Vector3d, radiusA: number, radiusB: number, capped?: boolean): Cone | undefined;
|
|
56
81
|
/** (Property accessor) Return the center point at the base plane */
|
|
57
82
|
getCenterA(): Point3d;
|
|
58
83
|
/** (Property accessor) */
|
|
@@ -65,7 +90,7 @@ export declare class Cone extends SolidPrimitive implements UVSurface, UVSurface
|
|
|
65
90
|
getRadiusA(): number;
|
|
66
91
|
/** (Property accessor) return the radius at the top plane */
|
|
67
92
|
getRadiusB(): number;
|
|
68
|
-
/** (Property accessor) return the larger of
|
|
93
|
+
/** (Property accessor) return the larger of radiusA and radiusB */
|
|
69
94
|
getMaxRadius(): number;
|
|
70
95
|
/** (Property accessor) return the radius at fraction `v` along the axis */
|
|
71
96
|
vFractionToRadius(v: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cone.d.ts","sourceRoot":"","sources":["../../../src/solid/Cone.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAE3G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,QAAQ,EA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AC7B,2EAA2E;IACpE,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAC3C,mEAAmE;IAC5D,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAC/C,iEAAiE;IACjD,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAS5D,wEAAwE;IACjE,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG;IAI/D;;;;;;;;;;OAUG;IACI,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY;IAwD1G;;;OAGG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAQvE,kEAAkE;IAC3D,WAAW,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;IAMvE;;;;OAIG;IACI,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAOzF;;;;OAIG;IACI,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,yBAAyB,GAAG,yBAAyB;IAaxI;;OAEG;IACH,IAAW,cAAc,IAAI,OAAO,CAEnC;IACD;;;;OAIG;IACI,wBAAwB,IAAI,QAAQ;CAY5C"}
|
package/lib/cjs/solid/Cone.js
CHANGED
|
@@ -19,20 +19,31 @@ const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
|
|
|
19
19
|
const Transform_1 = require("../geometry3d/Transform");
|
|
20
20
|
const SolidPrimitive_1 = require("./SolidPrimitive");
|
|
21
21
|
/**
|
|
22
|
-
* A cone with axis along the z
|
|
23
|
-
*
|
|
24
|
-
* *
|
|
25
|
-
* * Either
|
|
26
|
-
* *
|
|
22
|
+
* A cone with axis along the z-axis of a (possibly skewed) local coordinate system.
|
|
23
|
+
* * The curved surface of the cone `C` with axis `vectorZ = centerB - centerA` is parameterized over (u,v) in [0,1]x[0,1] by
|
|
24
|
+
* `C(u,v) = centerA + vFractionToRadius(v) * (cos(u * 2pi) * vectorX + sin(u * 2pi) * vectorY) + v * vectorZ`.
|
|
25
|
+
* * Either radius may be zero, but they may not both be zero.
|
|
26
|
+
* * Cross section size is determined by the lengths of `vectorX`, `vectorY`, and the radii.
|
|
27
|
+
* * If `vectorX` and `vectorY` are orthonormal, the cross sections are circular, with sections at v = 0 and v = 1 having radius
|
|
28
|
+
* `radiusA` and `radiusB`, respectively; otherwise, the cross sections are elliptical.
|
|
29
|
+
* * The stored matrix encapsulates `vectorX`, `vectorY`, and `vectorZ` in the respective columns. Typically the first two columns
|
|
30
|
+
* are orthogonal and unit length, and the last is full length.
|
|
31
|
+
* * Creating a Cone without orthogonal xy-axes of equal length is possible, but not recommended, for the resulting geometry
|
|
32
|
+
* lacks portability; for example, such a Cone cannot be represented as a DGN element (see [[createDgnCone]]).
|
|
27
33
|
* @public
|
|
28
34
|
*/
|
|
29
35
|
class Cone extends SolidPrimitive_1.SolidPrimitive {
|
|
30
36
|
/** String name for schema properties */
|
|
31
37
|
solidPrimitiveType = "cone";
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
/** Local to world transform. Axes may have any nonzero length and may be non-perpendicular. */
|
|
39
|
+
_localToWorld;
|
|
40
|
+
/** Nominal cross sectional radius at z=0 (scales the cone's xy-axes). */
|
|
41
|
+
_radiusA;
|
|
42
|
+
/** Nominal cross sectional radius at z=1 (scales the cone's xy-axes). */
|
|
43
|
+
_radiusB;
|
|
44
|
+
/** Maximum of _radiusA and _radiusB. */
|
|
45
|
+
_maxRadius;
|
|
46
|
+
/** Constructor, inputs CONSUMED. */
|
|
36
47
|
constructor(map, radiusA, radiusB, capped) {
|
|
37
48
|
super(capped);
|
|
38
49
|
this._localToWorld = map;
|
|
@@ -70,10 +81,11 @@ class Cone extends SolidPrimitive_1.SolidPrimitive {
|
|
|
70
81
|
const result = this.clone();
|
|
71
82
|
return result.tryTransformInPlace(transform) ? result : undefined;
|
|
72
83
|
}
|
|
73
|
-
/**
|
|
74
|
-
* from
|
|
75
|
-
* *
|
|
76
|
-
* *
|
|
84
|
+
/**
|
|
85
|
+
* Create a right circular cylinder or cone from the given base centers and radii.
|
|
86
|
+
* * The circular cross sections are perpendicular to the axis line between the centers.
|
|
87
|
+
* * Both radii must be of the same sign, and at least one radius must be nonzero.
|
|
88
|
+
* * Negative radii are accepted to create an interior surface, however the downstream effects of this, combined with capping, may be problematic.
|
|
77
89
|
*/
|
|
78
90
|
static createAxisPoints(centerA, centerB, radiusA, radiusB, capped) {
|
|
79
91
|
const zDirection = centerA.vectorTo(centerB);
|
|
@@ -92,17 +104,37 @@ class Cone extends SolidPrimitive_1.SolidPrimitive {
|
|
|
92
104
|
const matrix = Matrix3d_1.Matrix3d.createRigidHeadsUp(zDirection);
|
|
93
105
|
matrix.scaleColumns(1.0, 1.0, a, matrix);
|
|
94
106
|
const localToWorld = Transform_1.Transform.createOriginAndMatrix(centerA, matrix);
|
|
95
|
-
return new Cone(localToWorld, radiusA, radiusB, capped);
|
|
107
|
+
return new Cone(localToWorld, radiusA, radiusB, capped ?? false);
|
|
96
108
|
}
|
|
97
|
-
/**
|
|
98
|
-
* to the
|
|
109
|
+
/**
|
|
110
|
+
* Create a general cone from cross sections parallel to the plane spanned by the given vectors.
|
|
111
|
+
* * Circular cross sections are indicated by perpendicular vectors of the same length.
|
|
112
|
+
* * Elliptical cross sections are indicated by non-perpendicular vectors, or vectors of different lengths.
|
|
113
|
+
* * Cross sectional planes do not have to be perpendicular to the axis line between centers.
|
|
114
|
+
* * Cross section size is affected both by the given vector lengths and radii. To avoid unexpected scaling,
|
|
115
|
+
* pass orthonormal vectors for circular cross sections, or unit radii for elliptical cross sections.
|
|
116
|
+
* * There is no validation of the input radii. For best results, they should be nonnegative, and at least one should be nonzero.
|
|
99
117
|
*/
|
|
100
118
|
static createBaseAndTarget(centerA, centerB, vectorX, vectorY, radiusA, radiusB, capped) {
|
|
101
119
|
radiusA = Math.abs(Geometry_1.Geometry.correctSmallMetricDistance(radiusA));
|
|
102
120
|
radiusB = Math.abs(Geometry_1.Geometry.correctSmallMetricDistance(radiusB));
|
|
103
121
|
const vectorZ = centerA.vectorTo(centerB);
|
|
104
122
|
const localToWorld = Transform_1.Transform.createOriginAndMatrixColumns(centerA, vectorX, vectorY, vectorZ);
|
|
105
|
-
return new Cone(localToWorld, radiusA, radiusB, capped);
|
|
123
|
+
return new Cone(localToWorld, radiusA, radiusB, capped ?? false);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create a circular cone from the typical parameters of the DGN file.
|
|
127
|
+
* * This method calls [[createBaseAndTarget]] with normalized vectors, `vectorY` squared against `vectorX`, and
|
|
128
|
+
* `radiusA` and `radiusB` scaled by the original length of `vectorX`.
|
|
129
|
+
* * These restrictions allow the cone to be represented by an element in the DGN file.
|
|
130
|
+
*/
|
|
131
|
+
static createDgnCone(centerA, centerB, vectorX, vectorY, radiusA, radiusB, capped) {
|
|
132
|
+
const rigidMatrix = Matrix3d_1.Matrix3d.createRigidFromColumns(vectorX, vectorY, Geometry_1.AxisOrder.XYZ);
|
|
133
|
+
if (rigidMatrix) {
|
|
134
|
+
const vectorXMag = vectorX.magnitude();
|
|
135
|
+
return this.createBaseAndTarget(centerA, centerB, rigidMatrix.columnX(), rigidMatrix.columnY(), radiusA * vectorXMag, radiusB * vectorXMag, capped);
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
106
138
|
}
|
|
107
139
|
/** (Property accessor) Return the center point at the base plane */
|
|
108
140
|
getCenterA() { return this._localToWorld.multiplyXYZ(0, 0, 0); }
|
|
@@ -116,7 +148,7 @@ class Cone extends SolidPrimitive_1.SolidPrimitive {
|
|
|
116
148
|
getRadiusA() { return this._radiusA; }
|
|
117
149
|
/** (Property accessor) return the radius at the top plane */
|
|
118
150
|
getRadiusB() { return this._radiusB; }
|
|
119
|
-
/** (Property accessor) return the larger of
|
|
151
|
+
/** (Property accessor) return the larger of radiusA and radiusB */
|
|
120
152
|
getMaxRadius() { return this._maxRadius; }
|
|
121
153
|
/** (Property accessor) return the radius at fraction `v` along the axis */
|
|
122
154
|
vFractionToRadius(v) { return Geometry_1.Geometry.interpolate(this._radiusA, v, this._radiusB); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cone.js","sourceRoot":"","sources":["../../../src/solid/Cone.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AAGvC,wDAAqD;AACrD,wCAAqC;AAErC,0CAAuC;AAEvC,qDAAkD;AAClD,uFAAoF;AACpF,mEAAyD;AACzD,mEAAkE;AAElE,uDAAoD;AACpD,qDAAkD;AAElD;;;;;;;GAOG;AACH,MAAa,IAAK,SAAQ,+BAAc;IACtC,wCAAwC;IACxB,kBAAkB,GAAG,MAAM,CAAC;IAEpC,aAAa,CAAY,CAAO,kCAAkC;IAClE,QAAQ,CAAS,CAAI,6DAA6D;IAClF,QAAQ,CAAS,CAAI,qDAAqD;IAC1E,UAAU,CAAS,CAAC,uCAAuC;IACnE,YAAsB,GAAc,EAAE,OAAe,EAAE,OAAe,EAAE,MAAe;QACrF,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAE,2CAA2C;IACxG,CAAC;IACD,mCAAmC;IAC5B,KAAK;QACV,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,EA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AAG,QAAQ,GAAG,MAAM,EAAE,CAAC,CAAC,EACtF,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,CAAC,EAC3E,MAAM,CAAC,CAAC;IACZ,CAAC;IACD;;OAEG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD;;;;OAIG;IACI,wBAAwB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAEpD,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAE,CAAC;QACpD,MAAM,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACrD,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,0BAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACzE,mBAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;CACF;AAxPD,oBAwPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Solid\n */\n\nimport { Arc3d } from \"../curve/Arc3d\";\nimport { CurveCollection } from \"../curve/CurveCollection\";\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\nimport { LineString3d } from \"../curve/LineString3d\";\nimport { Loop } from \"../curve/Loop\";\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\nimport { Geometry } from \"../Geometry\";\nimport { GeometryHandler, UVSurface, UVSurfaceIsoParametricDistance } from \"../geometry3d/GeometryHandler\";\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\nimport { Vector2d } from \"../geometry3d/Point2dVector2d\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Range3d } from \"../geometry3d/Range\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { SolidPrimitive } from \"./SolidPrimitive\";\n\n/**\n * A cone with axis along the z axis of a (possibly skewed) local coordinate system.\n *\n * * In local coordinates, the sections at z=0 and z=1 are circles of radius r0 and r1.\n * * Either one individually may be zero, but they may not both be zero.\n * * The stored matrix has unit vectors in the xy columns, and full-length z column.\n * @public\n */\nexport class Cone extends SolidPrimitive implements UVSurface, UVSurfaceIsoParametricDistance {\n /** String name for schema properties */\n public readonly solidPrimitiveType = \"cone\";\n\n private _localToWorld: Transform; // Transform from local to global.\n private _radiusA: number; // nominal radius at z=0. skewed axes may make it an ellipse\n private _radiusB: number; // radius at z=1. skewed axes may make it an ellipse\n private _maxRadius: number; // maximum radius anywhere on the cone.\n protected constructor(map: Transform, radiusA: number, radiusB: number, capped: boolean) {\n super(capped);\n this._localToWorld = map;\n this._radiusA = radiusA;\n this._radiusB = radiusB;\n this._maxRadius = Math.max(this._radiusA, this._radiusB); // um... should resolve elliptical sections\n }\n /** Return a clone of this Cone. */\n public clone(): Cone {\n return new Cone(this._localToWorld.clone(), this._radiusA, this._radiusB, this.capped);\n }\n /** Return a coordinate frame (right handed unit vectors)\n * * origin at center of the base circle.\n * * base circle in the xy plane\n * * z axis by right hand rule.\n */\n public getConstructiveFrame(): Transform | undefined {\n return this._localToWorld.cloneRigid();\n }\n /** Apply the transform to this cone's local to world coordinates.\n * * Note that the radii are not changed. Scaling is absorbed into the frame.\n * * This fails if the transformation is singular.\n */\n public tryTransformInPlace(transform: Transform): boolean {\n if (transform.matrix.isSingular())\n return false;\n transform.multiplyTransformTransform(this._localToWorld, this._localToWorld);\n return true;\n }\n /**\n * Create a clone and immediately transform the clone.\n * * This fails if the transformation is singular.\n */\n public cloneTransformed(transform: Transform): Cone | undefined {\n const result = this.clone();\n return result.tryTransformInPlace(transform) ? result : undefined;\n }\n /** create a cylinder or cone from two endpoints and their radii. The circular cross sections are perpendicular to the axis line\n * from start to end point.\n * * both radii must be of the same sign.\n * * negative radius is accepted to create interior surface. Downstream effects of that combined with capping may be a problem.\n */\n public static createAxisPoints(centerA: Point3d, centerB: Point3d, radiusA: number, radiusB: number, capped: boolean): Cone | undefined {\n const zDirection = centerA.vectorTo(centerB);\n const a = zDirection.magnitude();\n if (Geometry.isSmallMetricDistance(a)) return undefined;\n // force near-zero radii to true zero\n radiusA = Geometry.correctSmallMetricDistance(radiusA);\n radiusB = Geometry.correctSmallMetricDistance(radiusB);\n // cone tip may not be \"within\" the z range.\n if (radiusA * radiusB < 0.0) return undefined;\n // at least one must be nonzero.\n if (radiusA + radiusB === 0.0) return undefined;\n const matrix = Matrix3d.createRigidHeadsUp(zDirection);\n matrix.scaleColumns(1.0, 1.0, a, matrix);\n const localToWorld = Transform.createOriginAndMatrix(centerA, matrix);\n return new Cone(localToWorld, radiusA, radiusB, capped);\n }\n /** create a cylinder or cone from axis start and end with cross section defined by vectors that do not need to be perpendicular to each other or\n * to the axis.\n */\n public static createBaseAndTarget(centerA: Point3d, centerB: Point3d, vectorX: Vector3d, vectorY: Vector3d, radiusA: number, radiusB: number, capped: boolean) {\n radiusA = Math.abs(Geometry.correctSmallMetricDistance(radiusA));\n radiusB = Math.abs(Geometry.correctSmallMetricDistance(radiusB));\n const vectorZ = centerA.vectorTo(centerB);\n const localToWorld = Transform.createOriginAndMatrixColumns(centerA, vectorX, vectorY, vectorZ);\n return new Cone(localToWorld, radiusA, radiusB, capped);\n }\n /** (Property accessor) Return the center point at the base plane */\n public getCenterA(): Point3d { return this._localToWorld.multiplyXYZ(0, 0, 0); }\n /** (Property accessor) */\n public getCenterB(): Point3d { return this._localToWorld.multiplyXYZ(0, 0, 1); }\n /** (Property accessor) Return the x vector in the local frame */\n public getVectorX(): Vector3d { return this._localToWorld.matrix.columnX(); }\n /** (Property accessor) Return the y vector in the local frame */\n public getVectorY(): Vector3d { return this._localToWorld.matrix.columnY(); }\n /** (Property accessor) return the radius at the base plane */\n public getRadiusA(): number { return this._radiusA; }\n /** (Property accessor) return the radius at the top plane */\n public getRadiusB(): number { return this._radiusB; }\n /** (Property accessor) return the larger of the base and top plane radii */\n public getMaxRadius(): number { return this._maxRadius; }\n /** (Property accessor) return the radius at fraction `v` along the axis */\n public vFractionToRadius(v: number): number { return Geometry.interpolate(this._radiusA, v, this._radiusB); }\n /** (Property accessor) test if `other` is an instance of `Cone` */\n public isSameGeometryClass(other: any): boolean { return other instanceof Cone; }\n /** (Property accessor) Test for nearly equal coordinate data. */\n public override isAlmostEqual(other: GeometryQuery): boolean {\n if (other instanceof Cone) {\n if (this.capped !== other.capped) return false;\n if (!this._localToWorld.isAlmostEqualAllowZRotation(other._localToWorld)) return false;\n return Geometry.isSameCoordinate(this._radiusA, other._radiusA)\n && Geometry.isSameCoordinate(this._radiusB, other._radiusB);\n }\n return false;\n }\n /** Second step of double dispatch: call `handler.handleCone(this)` */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return handler.handleCone(this);\n }\n\n /**\n * return strokes for a cross-section (elliptic arc) at specified fraction v along the axis.\n * * fixedStrokeCount takes priority over stroke options.\n * * The linestring is created by LineString3d.createForStrokes (fixedStrokeCount, options), which sets up property according to the options:\n * * optional fractions member\n * * optional uvParams. uvParams are installed as full-scale distance parameters.\n * * optional derivatives.\n * @param v fractional position along the cone axis\n * @param fixedStrokeCount optional stroke count.\n * @param options optional stroke options.\n */\n public strokeConstantVSection(v: number, fixedStrokeCount?: number, options?: StrokeOptions): LineString3d {\n let strokeCount = 16;\n if (fixedStrokeCount !== undefined)\n strokeCount = fixedStrokeCount;\n else if (options !== undefined)\n strokeCount = options.defaultCircleStrokes; // NEEDS WORK -- get circle stroke count with this.maxRadius !!!\n else {\n // accept the local default\n }\n strokeCount = Geometry.clampToStartEnd(strokeCount, 4, 64);\n const r = this.vFractionToRadius(v);\n const result = LineString3d.createForStrokes(fixedStrokeCount, options);\n const twoPi = Math.PI * 2.0;\n const deltaRadians = twoPi / strokeCount;\n let radians = 0;\n const fractions = result.fractions; // possibly undefined !!!\n const derivatives = result.packedDerivatives; // possibly undefined !!!\n const uvParams = result.packedUVParams; // possibly undefined !!\n const surfaceNormals = result.packedSurfaceNormals;\n const xyz = Point3d.create();\n const dXdu = Vector3d.create();\n const dXdv = Vector3d.create();\n const normal = Vector3d.create();\n const transform = this._localToWorld;\n let rc, rs, cc, ss;\n for (let i = 0; i <= strokeCount; i++) {\n if (i * 2 <= strokeCount)\n radians = i * deltaRadians;\n else\n radians = (i - strokeCount) * deltaRadians;\n cc = Math.cos(radians);\n ss = Math.sin(radians);\n rc = r * cc;\n rs = r * ss;\n\n transform.multiplyXYZ(rc, rs, v, xyz);\n result.addPoint(xyz);\n if (fractions)\n fractions.push(i / strokeCount);\n if (derivatives) {\n transform.matrix.multiplyXYZ(-rs * twoPi, rc * twoPi, 0.0, dXdu);\n derivatives.push(dXdu);\n }\n if (surfaceNormals) {\n // the along-hoop vector does not need to be scaled by radius -- just need the direction for a cross product.\n transform.matrix.multiplyXYZ(-ss, cc, 0.0, dXdu);\n transform.matrix.multiplyXYZ(0, 0, 1, dXdv);\n dXdu.unitCrossProduct(dXdv, normal);\n surfaceNormals.push(normal);\n }\n if (uvParams) {\n uvParams.pushXY(i / strokeCount, v);\n }\n }\n return result;\n }\n /**\n * Return the Arc3d section at vFraction\n * @param vFraction fractional position along the sweep direction\n */\n public constantVSection(vFraction: number): CurveCollection | undefined {\n const r = this.vFractionToRadius(vFraction);\n const transform = this._localToWorld;\n const center = transform.multiplyXYZ(0, 0, vFraction);\n const vector0 = transform.matrix.multiplyXYZ(r, 0, 0);\n const vector90 = transform.matrix.multiplyXYZ(0, r, 0);\n return Loop.create(Arc3d.create(center, vector0, vector90));\n }\n /** Extend `rangeToExtend` so it includes this `Cone` instance. */\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n const arc0 = this.constantVSection(0.0)!;\n const arc1 = this.constantVSection(1.0)!;\n arc0.extendRange(rangeToExtend, transform);\n arc1.extendRange(rangeToExtend, transform);\n }\n /** Evaluate a point on the Cone surfaces, with\n * * v = 0 is the base plane.\n * * v = 1 is the top plane\n * * u = 0 to u = 1 wraps the angular range.\n */\n public uvFractionToPoint(uFraction: number, vFraction: number, result?: Point3d): Point3d {\n const theta = uFraction * Math.PI * 2.0;\n const r = Geometry.interpolate(this._radiusA, vFraction, this._radiusB);\n const cosTheta = Math.cos(theta);\n const sinTheta = Math.sin(theta);\n return this._localToWorld.multiplyXYZ(r * cosTheta, r * sinTheta, vFraction, result);\n }\n /** Evaluate a point tangent plane on the Cone surfaces, with\n * * v = 0 is the base plane.\n * * v = 1 is the top plane\n * * u = 0 to u = 1 wraps the angular range.\n */\n public uvFractionToPointAndTangents(uFraction: number, vFraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\n const theta = uFraction * Math.PI * 2.0;\n const r = Geometry.interpolate(this._radiusA, vFraction, this._radiusB);\n const drdv = this._radiusB - this._radiusA;\n const cosTheta = Math.cos(theta);\n const sinTheta = Math.sin(theta);\n const fTheta = 2.0 * Math.PI;\n return Plane3dByOriginAndVectors.createOriginAndVectors(\n this._localToWorld.multiplyXYZ(r * cosTheta, r * sinTheta, vFraction),\n this._localToWorld.multiplyVectorXYZ(-r * sinTheta * fTheta, r * cosTheta * fTheta, 0),\n this._localToWorld.multiplyVectorXYZ(drdv * cosTheta, drdv * sinTheta, 1.0),\n result);\n }\n /**\n * @return true if this is a closed volume.\n */\n public get isClosedVolume(): boolean {\n return this.capped;\n }\n /**\n * Directional distance query\n * * u direction is around longitude circle at maximum distance from axis.\n * * v direction is on a line of longitude between the latitude limits.\n */\n public maxIsoParametricDistance(): Vector2d {\n const vectorX = this._localToWorld.matrix.columnX();\n const vectorY = this._localToWorld.matrix.columnY();\n const columnZ = this._localToWorld.matrix.columnZ();\n\n const xyNormal = vectorX.unitCrossProduct(vectorY)!;\n const hZ = xyNormal.dotProduct(columnZ);\n const zSkewVector = columnZ.plusScaled(xyNormal, hZ);\n const zSkewDistance = zSkewVector.magnitudeXY();\n return Vector2d.create(Math.PI * 2 * Math.max(this._radiusA, this._radiusB),\n Geometry.hypotenuseXY(Math.abs(this._radiusB - this._radiusA) + zSkewDistance, hZ));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Cone.js","sourceRoot":"","sources":["../../../src/solid/Cone.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AAGvC,wDAAqD;AACrD,wCAAqC;AAErC,0CAAkD;AAElD,qDAAkD;AAClD,uFAAoF;AACpF,mEAAyD;AACzD,mEAAkE;AAElE,uDAAoD;AACpD,qDAAkD;AAElD;;;;;;;;;;;;;GAaG;AACH,MAAa,IAAK,SAAQ,+BAAc;IACtC,wCAAwC;IACxB,kBAAkB,GAAG,MAAM,CAAC;IAE5C,+FAA+F;IACvF,aAAa,CAAY;IACjC,yEAAyE;IACjE,QAAQ,CAAS;IACzB,yEAAyE;IACjE,QAAQ,CAAS;IACzB,wCAAwC;IAChC,UAAU,CAAS;IAE3B,oCAAoC;IACpC,YAAsB,GAAc,EAAE,OAAe,EAAE,OAAe,EAAE,MAAe;QACrF,KAAK,CAAC,M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IACD;;;;OAIG;IACI,wBAAwB;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAEpD,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAE,CAAC;QACpD,MAAM,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACrD,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,0BAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACzE,mBAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;CACF;AArRD,oBAqRC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Solid\n */\n\nimport { Arc3d } from \"../curve/Arc3d\";\nimport { CurveCollection } from \"../curve/CurveCollection\";\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\nimport { LineString3d } from \"../curve/LineString3d\";\nimport { Loop } from \"../curve/Loop\";\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\nimport { AxisOrder, Geometry } from \"../Geometry\";\nimport { GeometryHandler, UVSurface, UVSurfaceIsoParametricDistance } from \"../geometry3d/GeometryHandler\";\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\nimport { Vector2d } from \"../geometry3d/Point2dVector2d\";\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\nimport { Range3d } from \"../geometry3d/Range\";\nimport { Transform } from \"../geometry3d/Transform\";\nimport { SolidPrimitive } from \"./SolidPrimitive\";\n\n/**\n * A cone with axis along the z-axis of a (possibly skewed) local coordinate system.\n * * The curved surface of the cone `C` with axis `vectorZ = centerB - centerA` is parameterized over (u,v) in [0,1]x[0,1] by\n * `C(u,v) = centerA + vFractionToRadius(v) * (cos(u * 2pi) * vectorX + sin(u * 2pi) * vectorY) + v * vectorZ`.\n * * Either radius may be zero, but they may not both be zero.\n * * Cross section size is determined by the lengths of `vectorX`, `vectorY`, and the radii.\n * * If `vectorX` and `vectorY` are orthonormal, the cross sections are circular, with sections at v = 0 and v = 1 having radius\n * `radiusA` and `radiusB`, respectively; otherwise, the cross sections are elliptical.\n * * The stored matrix encapsulates `vectorX`, `vectorY`, and `vectorZ` in the respective columns. Typically the first two columns\n * are orthogonal and unit length, and the last is full length.\n * * Creating a Cone without orthogonal xy-axes of equal length is possible, but not recommended, for the resulting geometry\n * lacks portability; for example, such a Cone cannot be represented as a DGN element (see [[createDgnCone]]).\n * @public\n */\nexport class Cone extends SolidPrimitive implements UVSurface, UVSurfaceIsoParametricDistance {\n /** String name for schema properties */\n public readonly solidPrimitiveType = \"cone\";\n\n /** Local to world transform. Axes may have any nonzero length and may be non-perpendicular. */\n private _localToWorld: Transform;\n /** Nominal cross sectional radius at z=0 (scales the cone's xy-axes). */\n private _radiusA: number;\n /** Nominal cross sectional radius at z=1 (scales the cone's xy-axes). */\n private _radiusB: number;\n /** Maximum of _radiusA and _radiusB. */\n private _maxRadius: number;\n\n /** Constructor, inputs CONSUMED. */\n protected constructor(map: Transform, radiusA: number, radiusB: number, capped: boolean) {\n super(capped);\n this._localToWorld = map;\n this._radiusA = radiusA;\n this._radiusB = radiusB;\n this._maxRadius = Math.max(this._radiusA, this._radiusB); // um... should resolve elliptical sections\n }\n /** Return a clone of this Cone. */\n public clone(): Cone {\n return new Cone(this._localToWorld.clone(), this._radiusA, this._radiusB, this.capped);\n }\n /** Return a coordinate frame (right handed unit vectors)\n * * origin at center of the base circle.\n * * base circle in the xy plane\n * * z axis by right hand rule.\n */\n public getConstructiveFrame(): Transform | undefined {\n return this._localToWorld.cloneRigid();\n }\n /** Apply the transform to this cone's local to world coordinates.\n * * Note that the radii are not changed. Scaling is absorbed into the frame.\n * * This fails if the transformation is singular.\n */\n public tryTransformInPlace(transform: Transform): boolean {\n if (transform.matrix.isSingular())\n return false;\n transform.multiplyTransformTransform(this._localToWorld, this._localToWorld);\n return true;\n }\n /**\n * Create a clone and immediately transform the clone.\n * * This fails if the transformation is singular.\n */\n public cloneTransformed(transform: Transform): Cone | undefined {\n const result = this.clone();\n return result.tryTransformInPlace(transform) ? result : undefined;\n }\n /**\n * Create a right circular cylinder or cone from the given base centers and radii.\n * * The circular cross sections are perpendicular to the axis line between the centers.\n * * Both radii must be of the same sign, and at least one radius must be nonzero.\n * * Negative radii are accepted to create an interior surface, however the downstream effects of this, combined with capping, may be problematic.\n */\n public static createAxisPoints(centerA: Point3d, centerB: Point3d, radiusA: number, radiusB: number, capped?: boolean): Cone | undefined {\n const zDirection = centerA.vectorTo(centerB);\n const a = zDirection.magnitude();\n if (Geometry.isSmallMetricDistance(a)) return undefined;\n // force near-zero radii to true zero\n radiusA = Geometry.correctSmallMetricDistance(radiusA);\n radiusB = Geometry.correctSmallMetricDistance(radiusB);\n // cone tip may not be \"within\" the z range.\n if (radiusA * radiusB < 0.0) return undefined;\n // at least one must be nonzero.\n if (radiusA + radiusB === 0.0) return undefined;\n const matrix = Matrix3d.createRigidHeadsUp(zDirection);\n matrix.scaleColumns(1.0, 1.0, a, matrix);\n const localToWorld = Transform.createOriginAndMatrix(centerA, matrix);\n return new Cone(localToWorld, radiusA, radiusB, capped ?? false);\n }\n /**\n * Create a general cone from cross sections parallel to the plane spanned by the given vectors.\n * * Circular cross sections are indicated by perpendicular vectors of the same length.\n * * Elliptical cross sections are indicated by non-perpendicular vectors, or vectors of different lengths.\n * * Cross sectional planes do not have to be perpendicular to the axis line between centers.\n * * Cross section size is affected both by the given vector lengths and radii. To avoid unexpected scaling,\n * pass orthonormal vectors for circular cross sections, or unit radii for elliptical cross sections.\n * * There is no validation of the input radii. For best results, they should be nonnegative, and at least one should be nonzero.\n */\n public static createBaseAndTarget(centerA: Point3d, centerB: Point3d, vectorX: Vector3d, vectorY: Vector3d, radiusA: number, radiusB: number, capped?: boolean): Cone {\n radiusA = Math.abs(Geometry.correctSmallMetricDistance(radiusA));\n radiusB = Math.abs(Geometry.correctSmallMetricDistance(radiusB));\n const vectorZ = centerA.vectorTo(centerB);\n const localToWorld = Transform.createOriginAndMatrixColumns(centerA, vectorX, vectorY, vectorZ);\n return new Cone(localToWorld, radiusA, radiusB, capped ?? false);\n }\n\n /**\n * Create a circular cone from the typical parameters of the DGN file.\n * * This method calls [[createBaseAndTarget]] with normalized vectors, `vectorY` squared against `vectorX`, and\n * `radiusA` and `radiusB` scaled by the original length of `vectorX`.\n * * These restrictions allow the cone to be represented by an element in the DGN file.\n */\n public static createDgnCone(centerA: Point3d, centerB: Point3d, vectorX: Vector3d, vectorY: Vector3d, radiusA: number, radiusB: number, capped?: boolean): Cone | undefined {\n const rigidMatrix = Matrix3d.createRigidFromColumns(vectorX, vectorY, AxisOrder.XYZ);\n if (rigidMatrix) {\n const vectorXMag = vectorX.magnitude();\n return this.createBaseAndTarget(centerA, centerB, rigidMatrix.columnX(), rigidMatrix.columnY(), radiusA * vectorXMag, radiusB * vectorXMag, capped);\n }\n return undefined;\n }\n\n /** (Property accessor) Return the center point at the base plane */\n public getCenterA(): Point3d { return this._localToWorld.multiplyXYZ(0, 0, 0); }\n /** (Property accessor) */\n public getCenterB(): Point3d { return this._localToWorld.multiplyXYZ(0, 0, 1); }\n /** (Property accessor) Return the x vector in the local frame */\n public getVectorX(): Vector3d { return this._localToWorld.matrix.columnX(); }\n /** (Property accessor) Return the y vector in the local frame */\n public getVectorY(): Vector3d { return this._localToWorld.matrix.columnY(); }\n /** (Property accessor) return the radius at the base plane */\n public getRadiusA(): number { return this._radiusA; }\n /** (Property accessor) return the radius at the top plane */\n public getRadiusB(): number { return this._radiusB; }\n /** (Property accessor) return the larger of radiusA and radiusB */\n public getMaxRadius(): number { return this._maxRadius; }\n /** (Property accessor) return the radius at fraction `v` along the axis */\n public vFractionToRadius(v: number): number { return Geometry.interpolate(this._radiusA, v, this._radiusB); }\n /** (Property accessor) test if `other` is an instance of `Cone` */\n public isSameGeometryClass(other: any): boolean { return other instanceof Cone; }\n /** (Property accessor) Test for nearly equal coordinate data. */\n public override isAlmostEqual(other: GeometryQuery): boolean {\n if (other instanceof Cone) {\n if (this.capped !== other.capped) return false;\n if (!this._localToWorld.isAlmostEqualAllowZRotation(other._localToWorld)) return false;\n return Geometry.isSameCoordinate(this._radiusA, other._radiusA)\n && Geometry.isSameCoordinate(this._radiusB, other._radiusB);\n }\n return false;\n }\n /** Second step of double dispatch: call `handler.handleCone(this)` */\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\n return handler.handleCone(this);\n }\n\n /**\n * return strokes for a cross-section (elliptic arc) at specified fraction v along the axis.\n * * fixedStrokeCount takes priority over stroke options.\n * * The linestring is created by LineString3d.createForStrokes (fixedStrokeCount, options), which sets up property according to the options:\n * * optional fractions member\n * * optional uvParams. uvParams are installed as full-scale distance parameters.\n * * optional derivatives.\n * @param v fractional position along the cone axis\n * @param fixedStrokeCount optional stroke count.\n * @param options optional stroke options.\n */\n public strokeConstantVSection(v: number, fixedStrokeCount?: number, options?: StrokeOptions): LineString3d {\n let strokeCount = 16;\n if (fixedStrokeCount !== undefined)\n strokeCount = fixedStrokeCount;\n else if (options !== undefined)\n strokeCount = options.defaultCircleStrokes; // NEEDS WORK -- get circle stroke count with this.maxRadius !!!\n else {\n // accept the local default\n }\n strokeCount = Geometry.clampToStartEnd(strokeCount, 4, 64);\n const r = this.vFractionToRadius(v);\n const result = LineString3d.createForStrokes(fixedStrokeCount, options);\n const twoPi = Math.PI * 2.0;\n const deltaRadians = twoPi / strokeCount;\n let radians = 0;\n const fractions = result.fractions; // possibly undefined !!!\n const derivatives = result.packedDerivatives; // possibly undefined !!!\n const uvParams = result.packedUVParams; // possibly undefined !!\n const surfaceNormals = result.packedSurfaceNormals;\n const xyz = Point3d.create();\n const dXdu = Vector3d.create();\n const dXdv = Vector3d.create();\n const normal = Vector3d.create();\n const transform = this._localToWorld;\n let rc, rs, cc, ss;\n for (let i = 0; i <= strokeCount; i++) {\n if (i * 2 <= strokeCount)\n radians = i * deltaRadians;\n else\n radians = (i - strokeCount) * deltaRadians;\n cc = Math.cos(radians);\n ss = Math.sin(radians);\n rc = r * cc;\n rs = r * ss;\n\n transform.multiplyXYZ(rc, rs, v, xyz);\n result.addPoint(xyz);\n if (fractions)\n fractions.push(i / strokeCount);\n if (derivatives) {\n transform.matrix.multiplyXYZ(-rs * twoPi, rc * twoPi, 0.0, dXdu);\n derivatives.push(dXdu);\n }\n if (surfaceNormals) {\n // the along-hoop vector does not need to be scaled by radius -- just need the direction for a cross product.\n transform.matrix.multiplyXYZ(-ss, cc, 0.0, dXdu);\n transform.matrix.multiplyXYZ(0, 0, 1, dXdv);\n dXdu.unitCrossProduct(dXdv, normal);\n surfaceNormals.push(normal);\n }\n if (uvParams) {\n uvParams.pushXY(i / strokeCount, v);\n }\n }\n return result;\n }\n /**\n * Return the Arc3d section at vFraction\n * @param vFraction fractional position along the sweep direction\n */\n public constantVSection(vFraction: number): CurveCollection | undefined {\n const r = this.vFractionToRadius(vFraction);\n const transform = this._localToWorld;\n const center = transform.multiplyXYZ(0, 0, vFraction);\n const vector0 = transform.matrix.multiplyXYZ(r, 0, 0);\n const vector90 = transform.matrix.multiplyXYZ(0, r, 0);\n return Loop.create(Arc3d.create(center, vector0, vector90));\n }\n /** Extend `rangeToExtend` so it includes this `Cone` instance. */\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n const arc0 = this.constantVSection(0.0)!;\n const arc1 = this.constantVSection(1.0)!;\n arc0.extendRange(rangeToExtend, transform);\n arc1.extendRange(rangeToExtend, transform);\n }\n /** Evaluate a point on the Cone surfaces, with\n * * v = 0 is the base plane.\n * * v = 1 is the top plane\n * * u = 0 to u = 1 wraps the angular range.\n */\n public uvFractionToPoint(uFraction: number, vFraction: number, result?: Point3d): Point3d {\n const theta = uFraction * Math.PI * 2.0;\n const r = Geometry.interpolate(this._radiusA, vFraction, this._radiusB);\n const cosTheta = Math.cos(theta);\n const sinTheta = Math.sin(theta);\n return this._localToWorld.multiplyXYZ(r * cosTheta, r * sinTheta, vFraction, result);\n }\n /** Evaluate a point tangent plane on the Cone surfaces, with\n * * v = 0 is the base plane.\n * * v = 1 is the top plane\n * * u = 0 to u = 1 wraps the angular range.\n */\n public uvFractionToPointAndTangents(uFraction: number, vFraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\n const theta = uFraction * Math.PI * 2.0;\n const r = Geometry.interpolate(this._radiusA, vFraction, this._radiusB);\n const drdv = this._radiusB - this._radiusA;\n const cosTheta = Math.cos(theta);\n const sinTheta = Math.sin(theta);\n const fTheta = 2.0 * Math.PI;\n return Plane3dByOriginAndVectors.createOriginAndVectors(\n this._localToWorld.multiplyXYZ(r * cosTheta, r * sinTheta, vFraction),\n this._localToWorld.multiplyVectorXYZ(-r * sinTheta * fTheta, r * cosTheta * fTheta, 0),\n this._localToWorld.multiplyVectorXYZ(drdv * cosTheta, drdv * sinTheta, 1.0),\n result);\n }\n /**\n * @return true if this is a closed volume.\n */\n public get isClosedVolume(): boolean {\n return this.capped;\n }\n /**\n * Directional distance query\n * * u direction is around longitude circle at maximum distance from axis.\n * * v direction is on a line of longitude between the latitude limits.\n */\n public maxIsoParametricDistance(): Vector2d {\n const vectorX = this._localToWorld.matrix.columnX();\n const vectorY = this._localToWorld.matrix.columnY();\n const columnZ = this._localToWorld.matrix.columnZ();\n\n const xyNormal = vectorX.unitCrossProduct(vectorY)!;\n const hZ = xyNormal.dotProduct(columnZ);\n const zSkewVector = columnZ.plusScaled(xyNormal, hZ);\n const zSkewDistance = zSkewVector.magnitudeXY();\n return Vector2d.create(Math.PI * 2 * Math.max(this._radiusA, this._radiusB),\n Geometry.hypotenuseXY(Math.abs(this._radiusB - this._radiusA) + zSkewDistance, hZ));\n }\n}\n"]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Solid
|
|
3
|
+
*/
|
|
4
|
+
import { Arc3d } from "../curve/Arc3d";
|
|
2
5
|
import { GeometryQuery } from "../curve/GeometryQuery";
|
|
3
6
|
import { LineString3d } from "../curve/LineString3d";
|
|
7
|
+
import { Loop } from "../curve/Loop";
|
|
4
8
|
import { StrokeOptions } from "../curve/StrokeOptions";
|
|
5
9
|
import { AngleSweep } from "../geometry3d/AngleSweep";
|
|
6
10
|
import { GeometryHandler, UVSurface } from "../geometry3d/GeometryHandler";
|
|
@@ -12,11 +16,11 @@ import { Range3d } from "../geometry3d/Range";
|
|
|
12
16
|
import { Transform } from "../geometry3d/Transform";
|
|
13
17
|
import { SolidPrimitive } from "./SolidPrimitive";
|
|
14
18
|
/**
|
|
15
|
-
* A
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* *
|
|
19
|
-
*
|
|
19
|
+
* A sphere mapped by an arbitrary transform.
|
|
20
|
+
* * Typically, the stored matrix has orthogonal columns. In this case, if two columns have equal length, the
|
|
21
|
+
* resulting geometry is ellipsoidal; if all three columns have equal length, the resulting geometry is a sphere.
|
|
22
|
+
* * Creating a Sphere without orthogonal columns is possible, but not recommended, for the resulting geometry
|
|
23
|
+
* lacks portability; for example, such a Sphere cannot be represented as a DGN element (see [[createDgnSphere]]).
|
|
20
24
|
* @public
|
|
21
25
|
*/
|
|
22
26
|
export declare class Sphere extends SolidPrimitive implements UVSurface {
|
|
@@ -42,22 +46,29 @@ export declare class Sphere extends SolidPrimitive implements UVSurface {
|
|
|
42
46
|
* * Fails if the transform is singular.
|
|
43
47
|
*/
|
|
44
48
|
cloneTransformed(transform: Transform): Sphere | undefined;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* *
|
|
48
|
-
* *
|
|
49
|
+
/**
|
|
50
|
+
* Construct a rigid coordinate frame from the local coordinate frame.
|
|
51
|
+
* * The returned frame is right-handed, with perpendicular unit axes.
|
|
52
|
+
* * Compare to [[cloneLocalToWorld]].
|
|
49
53
|
*/
|
|
50
54
|
getConstructiveFrame(): Transform | undefined;
|
|
51
55
|
/** Return the latitude sweep as fraction of south pole to north pole. */
|
|
52
56
|
get latitudeSweepFraction(): number;
|
|
53
57
|
/** Create from center and radius, with optional restricted latitudes. */
|
|
54
|
-
static createCenterRadius(center: Point3d, radius: number, latitudeSweep?: AngleSweep): Sphere;
|
|
58
|
+
static createCenterRadius(center: Point3d, radius: number, latitudeSweep?: AngleSweep, capped?: boolean): Sphere;
|
|
55
59
|
/** Create an ellipsoid which is a unit sphere mapped to position by an (arbitrary, possibly skewed and scaled) transform. */
|
|
56
|
-
static createEllipsoid(localToWorld: Transform, latitudeSweep
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
static createEllipsoid(localToWorld: Transform, latitudeSweep?: AngleSweep, capped?: boolean): Sphere | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Create a sphere from the typical parameters of the DGN file.
|
|
63
|
+
* * This method normalizes the input vectors, squares `vectorX` against `vectorZ`, and scales the radii by the vectors' original lengths.
|
|
64
|
+
* * These restrictions allow the sphere to be represented by an element in the DGN file.
|
|
65
|
+
*/
|
|
66
|
+
static createDgnSphere(center: Point3d, vectorX: Vector3d, vectorZ: Vector3d, radiusXY: number, radiusZ: number, latitudeSweep?: AngleSweep, capped?: boolean): Sphere | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Create a sphere.
|
|
69
|
+
* * If `axes` is supplied, its columns are scaled by the radii to form the sphere's local frame.
|
|
70
|
+
*/
|
|
71
|
+
static createFromAxesAndScales(center: Point3d, axes: undefined | Matrix3d, radiusX: number, radiusY: number, radiusZ: number, latitudeSweep?: AngleSweep, capped?: boolean): Sphere | undefined;
|
|
61
72
|
/** return (copy of) sphere center */
|
|
62
73
|
cloneCenter(): Point3d;
|
|
63
74
|
/** return the (full length, i.e. scaled by radius) X vector from the sphere transform */
|
|
@@ -76,6 +87,7 @@ export declare class Sphere extends SolidPrimitive implements UVSurface {
|
|
|
76
87
|
maxAxisRadius(): number;
|
|
77
88
|
/**
|
|
78
89
|
* Return a (clone of) the sphere's local to world transformation.
|
|
90
|
+
* * Compare to [[getConstructiveFrame]].
|
|
79
91
|
*/
|
|
80
92
|
cloneLocalToWorld(): Transform;
|
|
81
93
|
/** Test if `other` is a `Sphere` */
|
|
@@ -97,11 +109,16 @@ export declare class Sphere extends SolidPrimitive implements UVSurface {
|
|
|
97
109
|
strokeConstantVSection(v: number, fixedStrokeCount?: number, options?: StrokeOptions): LineString3d;
|
|
98
110
|
/** Second step of double dispatch: call `handler.handleSphere(this)` */
|
|
99
111
|
dispatchToGeometryHandler(handler: GeometryHandler): any;
|
|
112
|
+
/**
|
|
113
|
+
* Return the Arc3d section at uFraction. For the sphere, this is a meridian arc.
|
|
114
|
+
* @param uFraction fractional position along the equator.
|
|
115
|
+
*/
|
|
116
|
+
constantUSection(uFraction: number): Arc3d;
|
|
100
117
|
/**
|
|
101
118
|
* Return the Arc3d section at vFraction. For the sphere, this is a latitude circle.
|
|
102
119
|
* @param vFraction fractional position along the sweep direction
|
|
103
120
|
*/
|
|
104
|
-
constantVSection(vFraction: number):
|
|
121
|
+
constantVSection(vFraction: number): Loop;
|
|
105
122
|
/** Extend a range to contain this sphere. */
|
|
106
123
|
extendRange(range: Range3d, transform?: Transform): void;
|
|
107
124
|
/** Evaluate as a uv surface
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sphere.d.ts","sourceRoot":"","sources":["../../../src/solid/Sphere.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sphere.d.ts","sourceRoot":"","sources":["../../../src/solid/Sphere.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;GAOG;AACH,qBAAa,MAAO,SAAQ,cAAe,YAAW,SAAS;IAC7D,wCAAwC;IACxC,SAAgB,kBAAkB,YAAY;IAE9C,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,cAAc,CAAa;IACnC,yDAAy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cjs/solid/Sphere.js
CHANGED
|
@@ -13,6 +13,7 @@ const LineString3d_1 = require("../curve/LineString3d");
|
|
|
13
13
|
const Loop_1 = require("../curve/Loop");
|
|
14
14
|
const StrokeOptions_1 = require("../curve/StrokeOptions");
|
|
15
15
|
const Geometry_1 = require("../Geometry");
|
|
16
|
+
const Angle_1 = require("../geometry3d/Angle");
|
|
16
17
|
const AngleSweep_1 = require("../geometry3d/AngleSweep");
|
|
17
18
|
const Matrix3d_1 = require("../geometry3d/Matrix3d");
|
|
18
19
|
const Plane3dByOriginAndVectors_1 = require("../geometry3d/Plane3dByOriginAndVectors");
|
|
@@ -21,11 +22,11 @@ const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
|
|
|
21
22
|
const Transform_1 = require("../geometry3d/Transform");
|
|
22
23
|
const SolidPrimitive_1 = require("./SolidPrimitive");
|
|
23
24
|
/**
|
|
24
|
-
* A
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* *
|
|
28
|
-
*
|
|
25
|
+
* A sphere mapped by an arbitrary transform.
|
|
26
|
+
* * Typically, the stored matrix has orthogonal columns. In this case, if two columns have equal length, the
|
|
27
|
+
* resulting geometry is ellipsoidal; if all three columns have equal length, the resulting geometry is a sphere.
|
|
28
|
+
* * Creating a Sphere without orthogonal columns is possible, but not recommended, for the resulting geometry
|
|
29
|
+
* lacks portability; for example, such a Sphere cannot be represented as a DGN element (see [[createDgnSphere]]).
|
|
29
30
|
* @public
|
|
30
31
|
*/
|
|
31
32
|
class Sphere extends SolidPrimitive_1.SolidPrimitive {
|
|
@@ -72,10 +73,10 @@ class Sphere extends SolidPrimitive_1.SolidPrimitive {
|
|
|
72
73
|
const result = this.clone();
|
|
73
74
|
return result.tryTransformInPlace(transform) ? result : undefined;
|
|
74
75
|
}
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
* *
|
|
78
|
-
* *
|
|
76
|
+
/**
|
|
77
|
+
* Construct a rigid coordinate frame from the local coordinate frame.
|
|
78
|
+
* * The returned frame is right-handed, with perpendicular unit axes.
|
|
79
|
+
* * Compare to [[cloneLocalToWorld]].
|
|
79
80
|
*/
|
|
80
81
|
getConstructiveFrame() {
|
|
81
82
|
return this._localToWorld.cloneRigid();
|
|
@@ -83,30 +84,37 @@ class Sphere extends SolidPrimitive_1.SolidPrimitive {
|
|
|
83
84
|
/** Return the latitude sweep as fraction of south pole to north pole. */
|
|
84
85
|
get latitudeSweepFraction() { return this._latitudeSweep.sweepRadians / Math.PI; }
|
|
85
86
|
/** Create from center and radius, with optional restricted latitudes. */
|
|
86
|
-
static createCenterRadius(center, radius, latitudeSweep) {
|
|
87
|
+
static createCenterRadius(center, radius, latitudeSweep, capped) {
|
|
87
88
|
const localToWorld = Transform_1.Transform.createOriginAndMatrix(center, Matrix3d_1.Matrix3d.createUniformScale(radius));
|
|
88
|
-
return new Sphere(localToWorld, latitudeSweep ? latitudeSweep.clone() : AngleSweep_1.AngleSweep.createFullLatitude(), false);
|
|
89
|
+
return new Sphere(localToWorld, latitudeSweep ? latitudeSweep.clone() : AngleSweep_1.AngleSweep.createFullLatitude(), capped ?? false);
|
|
89
90
|
}
|
|
90
91
|
/** Create an ellipsoid which is a unit sphere mapped to position by an (arbitrary, possibly skewed and scaled) transform. */
|
|
91
92
|
static createEllipsoid(localToWorld, latitudeSweep, capped) {
|
|
92
|
-
return new Sphere(localToWorld.clone(), latitudeSweep.clone(), capped);
|
|
93
|
+
return new Sphere(localToWorld.clone(), latitudeSweep ? latitudeSweep.clone() : AngleSweep_1.AngleSweep.createFullLatitude(), capped ?? false);
|
|
93
94
|
}
|
|
94
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Create a sphere from the typical parameters of the DGN file.
|
|
97
|
+
* * This method normalizes the input vectors, squares `vectorX` against `vectorZ`, and scales the radii by the vectors' original lengths.
|
|
98
|
+
* * These restrictions allow the sphere to be represented by an element in the DGN file.
|
|
99
|
+
*/
|
|
95
100
|
static createDgnSphere(center, vectorX, vectorZ, radiusXY, radiusZ, latitudeSweep, capped) {
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const frame = Transform_1.Transform.createOriginAndMatrix(center,
|
|
101
|
-
return new Sphere(frame, latitudeSweep.clone(), capped);
|
|
101
|
+
const rigidMatrix = Matrix3d_1.Matrix3d.createRigidFromColumns(vectorZ, vectorX, Geometry_1.AxisOrder.ZXY);
|
|
102
|
+
if (rigidMatrix) {
|
|
103
|
+
radiusXY *= vectorX.magnitude();
|
|
104
|
+
rigidMatrix.scaleColumns(radiusXY, radiusXY, radiusZ * vectorZ.magnitude(), rigidMatrix);
|
|
105
|
+
const frame = Transform_1.Transform.createOriginAndMatrix(center, rigidMatrix);
|
|
106
|
+
return new Sphere(frame, latitudeSweep ? latitudeSweep.clone() : AngleSweep_1.AngleSweep.createFullLatitude(), capped ?? false);
|
|
102
107
|
}
|
|
103
108
|
return undefined;
|
|
104
109
|
}
|
|
105
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Create a sphere.
|
|
112
|
+
* * If `axes` is supplied, its columns are scaled by the radii to form the sphere's local frame.
|
|
113
|
+
*/
|
|
106
114
|
static createFromAxesAndScales(center, axes, radiusX, radiusY, radiusZ, latitudeSweep, capped) {
|
|
107
115
|
const localToWorld = Transform_1.Transform.createOriginAndMatrix(center, axes);
|
|
108
116
|
localToWorld.matrix.scaleColumnsInPlace(radiusX, radiusY, radiusZ);
|
|
109
|
-
return new Sphere(localToWorld, latitudeSweep ? latitudeSweep.clone() : AngleSweep_1.AngleSweep.createFullLatitude(), capped);
|
|
117
|
+
return new Sphere(localToWorld, latitudeSweep ? latitudeSweep.clone() : AngleSweep_1.AngleSweep.createFullLatitude(), capped ?? false);
|
|
110
118
|
}
|
|
111
119
|
/** return (copy of) sphere center */
|
|
112
120
|
cloneCenter() { return this._localToWorld.getOrigin(); }
|
|
@@ -136,8 +144,11 @@ class Sphere extends SolidPrimitive_1.SolidPrimitive {
|
|
|
136
144
|
}
|
|
137
145
|
/**
|
|
138
146
|
* Return a (clone of) the sphere's local to world transformation.
|
|
147
|
+
* * Compare to [[getConstructiveFrame]].
|
|
139
148
|
*/
|
|
140
|
-
cloneLocalToWorld() {
|
|
149
|
+
cloneLocalToWorld() {
|
|
150
|
+
return this._localToWorld.clone();
|
|
151
|
+
}
|
|
141
152
|
/** Test if `other` is a `Sphere` */
|
|
142
153
|
isSameGeometryClass(other) { return other instanceof Sphere; }
|
|
143
154
|
/** Test for same geometry in `other` */
|
|
@@ -218,6 +229,20 @@ class Sphere extends SolidPrimitive_1.SolidPrimitive {
|
|
|
218
229
|
dispatchToGeometryHandler(handler) {
|
|
219
230
|
return handler.handleSphere(this);
|
|
220
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Return the Arc3d section at uFraction. For the sphere, this is a meridian arc.
|
|
234
|
+
* @param uFraction fractional position along the equator.
|
|
235
|
+
*/
|
|
236
|
+
constantUSection(uFraction) {
|
|
237
|
+
const phi = AngleSweep_1.AngleSweep.fractionToSignedPeriodicFractionStartEnd(uFraction, 0, Angle_1.Angle.pi2Radians, false);
|
|
238
|
+
const s1 = Math.sin(phi);
|
|
239
|
+
const c1 = Math.cos(phi);
|
|
240
|
+
const transform = this._localToWorld;
|
|
241
|
+
const center = transform.getOrigin();
|
|
242
|
+
const vector0 = transform.matrix.multiplyXYZ(c1, s1, 0);
|
|
243
|
+
const vector90 = transform.matrix.multiplyXYZ(0, 0, 1);
|
|
244
|
+
return Arc3d_1.Arc3d.create(center, vector0, vector90, this._latitudeSweep);
|
|
245
|
+
}
|
|
221
246
|
/**
|
|
222
247
|
* Return the Arc3d section at vFraction. For the sphere, this is a latitude circle.
|
|
223
248
|
* @param vFraction fractional position along the sweep direction
|