@mlightcad/geometry-engine 3.11.2 → 3.12.0

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.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +177 -177
  3. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 mlightcad
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mlightcad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,178 +1,178 @@
1
- # @mlightcad/geometry-engine
2
-
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://img.shields.io/npm/v/@mlightcad/geometry-engine.svg)](https://www.npmjs.com/package/@mlightcad/geometry-engine)
5
-
6
- The geometry-engine package provides comprehensive geometric entities, mathematical operations, and transformations for 2D and 3D space. This package mimics AutoCAD ObjectARX's AcGe (Geometry) classes and provides the mathematical foundation for CAD operations.
7
-
8
- ## Overview
9
-
10
- This package consists of two main categories of classes:
11
-
12
- - **Math Classes**: Focus on mathematical operations that underpin geometric calculations, including vectors, matrices, transformations, and linear algebra operations
13
- - **Geometry Classes**: Focus on complex geometric entities and their operations, including lines, curves, surfaces, and intersections
14
-
15
- Most math classes are adapted from [THREE.js](https://threejs.org/docs/index.html) with modified class names to match AutoCAD ObjectARX conventions.
16
-
17
- ## Key Features
18
-
19
- - **2D and 3D Geometry**: Support for both 2D and 3D geometric operations
20
- - **Mathematical Foundation**: Comprehensive vector and matrix operations
21
- - **Curve and Surface Support**: Advanced geometric entities including splines and NURBS
22
- - **Transformation Utilities**: Matrix-based transformations for 2D and 3D space
23
- - **Intersection Calculations**: Tools for computing geometric intersections
24
- - **Performance Optimized**: Efficient mathematical operations for real-time CAD applications
25
-
26
- ## Installation
27
-
28
- ```bash
29
- npm install @mlightcad/geometry-engine
30
- ```
31
-
32
- ## Key Classes
33
-
34
- ### Math Classes (2D and 3D)
35
-
36
- #### Points and Vectors
37
- - **AcGePoint2d, AcGePoint3d**: Represent 2D and 3D points in space
38
- - **AcGeVector2d, AcGeVector3d**: Represent 2D and 3D vectors with magnitude and direction
39
-
40
- #### Transformations
41
- - **AcGeMatrix2d, AcGeMatrix3d**: 2D and 3D transformation matrices
42
- - **AcGeQuaternion**: Quaternion-based 3D rotations
43
- - **AcGeEuler**: Euler angle representations for 3D rotations
44
-
45
- #### Mathematical Utilities
46
- - **AcGeBox2d, AcGeBox3d**: Bounding boxes in 2D and 3D space
47
- - **AcGePlane**: 3D plane representations
48
- - **AcGeTol**: Tolerance settings for geometric comparisons
49
-
50
- ### Geometry Classes
51
-
52
- #### Basic Geometric Entities
53
- - **AcGeLine2d, AcGeLine3d**: Lines in 2D and 3D space
54
- - **AcGeCurve2d, AcGeCurve3d**: Abstract base classes for curves
55
- - **AcGeCircArc2d, AcGeCircArc3d**: Circular arcs in 2D and 3D
56
- - **AcGeEllipseArc2d, AcGeEllipseArc3d**: Elliptical arcs
57
-
58
- #### Complex Geometric Entities
59
- - **AcGePolyline2d**: 2D polyline with multiple segments
60
- - **AcGeSpline3d**: 3D spline curves
61
- - **AcGeShape2d, AcGeShape3d**: Complex geometric shapes
62
- - **AcGeArea2d**: 2D area calculations
63
- - **AcGeLoop2d**: 2D loop representations
64
-
65
- #### Utility Classes
66
- - **AcGeGeometryUtil**: Utility functions for geometric operations
67
- - **AcGeMathUtil**: Mathematical utility functions
68
- - **AcGeConstants**: Geometric constants and settings
69
-
70
- ## Usage Examples
71
-
72
- ### Basic Point and Vector Operations
73
- ```typescript
74
- import { AcGePoint3d, AcGeVector3d, AcGeMatrix3d } from '@mlightcad/geometry-engine';
75
-
76
- // Create points and vectors
77
- const point1 = new AcGePoint3d(0, 0, 0);
78
- const point2 = new AcGePoint3d(10, 10, 10);
79
- const vector = new AcGeVector3d(1, 0, 0);
80
-
81
- // Calculate distance between points
82
- const distance = point1.distanceTo(point2);
83
-
84
- // Transform a point
85
- const matrix = AcGeMatrix3d.translation(5, 5, 5);
86
- const transformedPoint = point1.transformBy(matrix);
87
- ```
88
-
89
- ### Line and Curve Operations
90
- ```typescript
91
- import { AcGeLine3d, AcGeCircArc3d, AcGePoint3d } from '@mlightcad/geometry-engine';
92
-
93
- // Create a line
94
- const startPoint = new AcGePoint3d(0, 0, 0);
95
- const endPoint = new AcGePoint3d(10, 0, 0);
96
- const line = new AcGeLine3d(startPoint, endPoint);
97
-
98
- // Create a circular arc
99
- const center = new AcGePoint3d(0, 0, 0);
100
- const radius = 5;
101
- const startAngle = 0;
102
- const endAngle = Math.PI / 2;
103
- const arc = new AcGeCircArc3d(center, radius, startAngle, endAngle);
104
-
105
- // Get points along the curve
106
- const param = 0.5;
107
- const pointOnLine = line.evalPoint(param);
108
- const pointOnArc = arc.evalPoint(param);
109
- ```
110
-
111
- ### Matrix Transformations
112
- ```typescript
113
- import { AcGeMatrix3d, AcGePoint3d } from '@mlightcad/geometry-engine';
114
-
115
- // Create transformation matrices
116
- const translation = AcGeMatrix3d.translation(10, 20, 30);
117
- const rotation = AcGeMatrix3d.rotation(Math.PI / 4, AcGeVector3d.kZAxis);
118
- const scale = AcGeMatrix3d.scaling(2, 2, 2);
119
-
120
- // Combine transformations
121
- const combined = translation.multiply(rotation).multiply(scale);
122
-
123
- // Apply transformation to a point
124
- const point = new AcGePoint3d(1, 1, 1);
125
- const transformed = point.transformBy(combined);
126
- ```
127
-
128
- ### Polyline Operations
129
- ```typescript
130
- import { AcGePolyline2d, AcGePoint2d } from '@mlightcad/geometry-engine';
131
-
132
- // Create a polyline
133
- const polyline = new AcGePolyline2d();
134
- polyline.addVertexAt(0, new AcGePoint2d(0, 0));
135
- polyline.addVertexAt(1, new AcGePoint2d(10, 0));
136
- polyline.addVertexAt(2, new AcGePoint2d(10, 10));
137
- polyline.addVertexAt(3, new AcGePoint2d(0, 10));
138
-
139
- // Close the polyline
140
- polyline.setClosed(true);
141
-
142
- // Get polyline properties
143
- const length = polyline.length();
144
- const area = polyline.area();
145
- const isClosed = polyline.isClosed();
146
- ```
147
-
148
- ### Geometric Utilities
149
- ```typescript
150
- import { AcGeGeometryUtil, AcGePoint3d, AcGeVector3d } from '@mlightcad/geometry-engine';
151
-
152
- // Calculate intersection between lines
153
- const line1 = new AcGeLine3d(new AcGePoint3d(0, 0, 0), new AcGeVector3d(1, 0, 0));
154
- const line2 = new AcGeLine3d(new AcGePoint3d(0, 0, 0), new AcGeVector3d(0, 1, 0));
155
-
156
- const intersection = AcGeGeometryUtil.intersect(line1, line2);
157
-
158
- // Check if points are collinear
159
- const points = [
160
- new AcGePoint3d(0, 0, 0),
161
- new AcGePoint3d(1, 1, 1),
162
- new AcGePoint3d(2, 2, 2)
163
- ];
164
-
165
- const areCollinear = AcGeGeometryUtil.areCollinear(points);
166
- ```
167
-
168
- ## Dependencies
169
-
170
- - **@mlightcad/common**: For common utilities (peer dependency)
171
-
172
- ## API Documentation
173
-
174
- For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
175
-
176
- ## Contributing
177
-
1
+ # @mlightcad/geometry-engine
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@mlightcad/geometry-engine.svg)](https://www.npmjs.com/package/@mlightcad/geometry-engine)
5
+
6
+ The geometry-engine package provides comprehensive geometric entities, mathematical operations, and transformations for 2D and 3D space. This package mimics AutoCAD ObjectARX's AcGe (Geometry) classes and provides the mathematical foundation for CAD operations.
7
+
8
+ ## Overview
9
+
10
+ This package consists of two main categories of classes:
11
+
12
+ - **Math Classes**: Focus on mathematical operations that underpin geometric calculations, including vectors, matrices, transformations, and linear algebra operations
13
+ - **Geometry Classes**: Focus on complex geometric entities and their operations, including lines, curves, surfaces, and intersections
14
+
15
+ Most math classes are adapted from [THREE.js](https://threejs.org/docs/index.html) with modified class names to match AutoCAD ObjectARX conventions.
16
+
17
+ ## Key Features
18
+
19
+ - **2D and 3D Geometry**: Support for both 2D and 3D geometric operations
20
+ - **Mathematical Foundation**: Comprehensive vector and matrix operations
21
+ - **Curve and Surface Support**: Advanced geometric entities including splines and NURBS
22
+ - **Transformation Utilities**: Matrix-based transformations for 2D and 3D space
23
+ - **Intersection Calculations**: Tools for computing geometric intersections
24
+ - **Performance Optimized**: Efficient mathematical operations for real-time CAD applications
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @mlightcad/geometry-engine
30
+ ```
31
+
32
+ ## Key Classes
33
+
34
+ ### Math Classes (2D and 3D)
35
+
36
+ #### Points and Vectors
37
+ - **AcGePoint2d, AcGePoint3d**: Represent 2D and 3D points in space
38
+ - **AcGeVector2d, AcGeVector3d**: Represent 2D and 3D vectors with magnitude and direction
39
+
40
+ #### Transformations
41
+ - **AcGeMatrix2d, AcGeMatrix3d**: 2D and 3D transformation matrices
42
+ - **AcGeQuaternion**: Quaternion-based 3D rotations
43
+ - **AcGeEuler**: Euler angle representations for 3D rotations
44
+
45
+ #### Mathematical Utilities
46
+ - **AcGeBox2d, AcGeBox3d**: Bounding boxes in 2D and 3D space
47
+ - **AcGePlane**: 3D plane representations
48
+ - **AcGeTol**: Tolerance settings for geometric comparisons
49
+
50
+ ### Geometry Classes
51
+
52
+ #### Basic Geometric Entities
53
+ - **AcGeLine2d, AcGeLine3d**: Lines in 2D and 3D space
54
+ - **AcGeCurve2d, AcGeCurve3d**: Abstract base classes for curves
55
+ - **AcGeCircArc2d, AcGeCircArc3d**: Circular arcs in 2D and 3D
56
+ - **AcGeEllipseArc2d, AcGeEllipseArc3d**: Elliptical arcs
57
+
58
+ #### Complex Geometric Entities
59
+ - **AcGePolyline2d**: 2D polyline with multiple segments
60
+ - **AcGeSpline3d**: 3D spline curves
61
+ - **AcGeShape2d, AcGeShape3d**: Complex geometric shapes
62
+ - **AcGeArea2d**: 2D area calculations
63
+ - **AcGeLoop2d**: 2D loop representations
64
+
65
+ #### Utility Classes
66
+ - **AcGeGeometryUtil**: Utility functions for geometric operations
67
+ - **AcGeMathUtil**: Mathematical utility functions
68
+ - **AcGeConstants**: Geometric constants and settings
69
+
70
+ ## Usage Examples
71
+
72
+ ### Basic Point and Vector Operations
73
+ ```typescript
74
+ import { AcGePoint3d, AcGeVector3d, AcGeMatrix3d } from '@mlightcad/geometry-engine';
75
+
76
+ // Create points and vectors
77
+ const point1 = new AcGePoint3d(0, 0, 0);
78
+ const point2 = new AcGePoint3d(10, 10, 10);
79
+ const vector = new AcGeVector3d(1, 0, 0);
80
+
81
+ // Calculate distance between points
82
+ const distance = point1.distanceTo(point2);
83
+
84
+ // Transform a point
85
+ const matrix = AcGeMatrix3d.translation(5, 5, 5);
86
+ const transformedPoint = point1.transformBy(matrix);
87
+ ```
88
+
89
+ ### Line and Curve Operations
90
+ ```typescript
91
+ import { AcGeLine3d, AcGeCircArc3d, AcGePoint3d } from '@mlightcad/geometry-engine';
92
+
93
+ // Create a line
94
+ const startPoint = new AcGePoint3d(0, 0, 0);
95
+ const endPoint = new AcGePoint3d(10, 0, 0);
96
+ const line = new AcGeLine3d(startPoint, endPoint);
97
+
98
+ // Create a circular arc
99
+ const center = new AcGePoint3d(0, 0, 0);
100
+ const radius = 5;
101
+ const startAngle = 0;
102
+ const endAngle = Math.PI / 2;
103
+ const arc = new AcGeCircArc3d(center, radius, startAngle, endAngle);
104
+
105
+ // Get points along the curve
106
+ const param = 0.5;
107
+ const pointOnLine = line.evalPoint(param);
108
+ const pointOnArc = arc.evalPoint(param);
109
+ ```
110
+
111
+ ### Matrix Transformations
112
+ ```typescript
113
+ import { AcGeMatrix3d, AcGePoint3d } from '@mlightcad/geometry-engine';
114
+
115
+ // Create transformation matrices
116
+ const translation = AcGeMatrix3d.translation(10, 20, 30);
117
+ const rotation = AcGeMatrix3d.rotation(Math.PI / 4, AcGeVector3d.kZAxis);
118
+ const scale = AcGeMatrix3d.scaling(2, 2, 2);
119
+
120
+ // Combine transformations
121
+ const combined = translation.multiply(rotation).multiply(scale);
122
+
123
+ // Apply transformation to a point
124
+ const point = new AcGePoint3d(1, 1, 1);
125
+ const transformed = point.transformBy(combined);
126
+ ```
127
+
128
+ ### Polyline Operations
129
+ ```typescript
130
+ import { AcGePolyline2d, AcGePoint2d } from '@mlightcad/geometry-engine';
131
+
132
+ // Create a polyline
133
+ const polyline = new AcGePolyline2d();
134
+ polyline.addVertexAt(0, new AcGePoint2d(0, 0));
135
+ polyline.addVertexAt(1, new AcGePoint2d(10, 0));
136
+ polyline.addVertexAt(2, new AcGePoint2d(10, 10));
137
+ polyline.addVertexAt(3, new AcGePoint2d(0, 10));
138
+
139
+ // Close the polyline
140
+ polyline.setClosed(true);
141
+
142
+ // Get polyline properties
143
+ const length = polyline.length();
144
+ const area = polyline.area();
145
+ const isClosed = polyline.isClosed();
146
+ ```
147
+
148
+ ### Geometric Utilities
149
+ ```typescript
150
+ import { AcGeGeometryUtil, AcGePoint3d, AcGeVector3d } from '@mlightcad/geometry-engine';
151
+
152
+ // Calculate intersection between lines
153
+ const line1 = new AcGeLine3d(new AcGePoint3d(0, 0, 0), new AcGeVector3d(1, 0, 0));
154
+ const line2 = new AcGeLine3d(new AcGePoint3d(0, 0, 0), new AcGeVector3d(0, 1, 0));
155
+
156
+ const intersection = AcGeGeometryUtil.intersect(line1, line2);
157
+
158
+ // Check if points are collinear
159
+ const points = [
160
+ new AcGePoint3d(0, 0, 0),
161
+ new AcGePoint3d(1, 1, 1),
162
+ new AcGePoint3d(2, 2, 2)
163
+ ];
164
+
165
+ const areCollinear = AcGeGeometryUtil.areCollinear(points);
166
+ ```
167
+
168
+ ## Dependencies
169
+
170
+ - **@mlightcad/common**: For common utilities (peer dependency)
171
+
172
+ ## API Documentation
173
+
174
+ For detailed API documentation, visit the [RealDWG-Web documentation](https://mlight-lee.github.io/realdwg-web/).
175
+
176
+ ## Contributing
177
+
178
178
  This package is part of the RealDWG-Web monorepo. Please refer to the main project README for contribution guidelines.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/geometry-engine",
3
- "version": "3.11.2",
3
+ "version": "3.12.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "require": "./dist/geometry-engine.umd.cjs"
34
34
  },
35
35
  "peerDependencies": {
36
- "@mlightcad/common": "1.11.2"
36
+ "@mlightcad/common": "1.12.0"
37
37
  },
38
38
  "scripts": {
39
39
  "clean": "rimraf dist lib tsconfig.tsbuildinfo",