Skip to content

Commit 781b9f8

Browse files
authored
Merge pull request #1260 from jsxcad/xform
Lazy matrix composition
2 parents a156683 + e6b0ad7 commit 781b9f8

File tree

75 files changed

+528
-1442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+528
-1442
lines changed

algorithm/cgal/Geometry.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ enum GeometryType {
180180
GEOMETRY_GROUP = 8,
181181
};
182182

183+
enum TransformType {
184+
TRANSFORM_COMPOSE = 0,
185+
TRANSFORM_EXACT = 1,
186+
TRANSFORM_APPROXIMATE = 2,
187+
TRANSFORM_INVERT = 3,
188+
TRANSFORM_ROTATE_X = 4,
189+
TRANSFORM_ROTATE_Y = 5,
190+
TRANSFORM_ROTATE_Z = 6,
191+
TRANSFORM_TRANSLATE = 7,
192+
TRANSFORM_SCALE = 8,
193+
TRANSFORM_IDENTITY = 9,
194+
};
195+
183196
#include "Edge.h"
184197

185198
class DN {

algorithm/cgal/cgal_browser.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

algorithm/cgal/cgal_browser.wasm

4.86 KB
Binary file not shown.

algorithm/cgal/computeArea.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { computeArea } from './computeArea.js';
22
import { initCgal } from './getCgal.js';
3+
import { makeApproximateMatrix } from './transform.js';
34

45
import test from 'ava';
56

@@ -35,7 +36,9 @@ test('Area of polygon with hole', (t) => {
3536
},
3637
],
3738
plane: [0, 0, 1, 0],
38-
matrix: [2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
39+
matrix: makeApproximateMatrix([
40+
2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
41+
]),
3942
},
4043
]);
4144
t.is(area.toFixed(4), (6).toFixed(4));
Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { computeCentroid } from './computeCentroid.js';
2+
import { identityMatrix } from './transform.js';
23
import { initCgal } from './getCgal.js';
34

45
import test from 'ava';
@@ -28,55 +29,19 @@ test('Compute Centroid', (t) => {
2829
],
2930
plane: [0, 0, 1, 0],
3031
exactPlane: '0 0 1 0',
31-
matrix: [
32-
1,
33-
0,
34-
0,
35-
1,
36-
0,
37-
1,
38-
0,
39-
0,
40-
0,
41-
0,
42-
1,
43-
0,
44-
0,
45-
0,
46-
0,
47-
1,
48-
'1 0 0 1 0 1 0 0 0 0 1 0 1',
49-
],
32+
matrix: identityMatrix,
5033
tags: [],
5134
},
5235
]);
5336
t.deepEqual(JSON.parse(JSON.stringify(centroid)), [
5437
{
5538
type: 'points',
56-
points: [[1, -5.551115123125783e-17, 0]],
39+
matrix: identityMatrix,
40+
tags: [],
41+
points: [[9.442564829413299e-17, -5.551115123125783e-17, 0]],
5742
exactPoints: [
58-
'243388915243820068069523124935687/243388915243820045087367015432192 -1/18014398509481984 0',
43+
'22982156109503495/243388915243820045087367015432192 -1/18014398509481984 0',
5944
],
60-
matrix: [
61-
1,
62-
0,
63-
0,
64-
0,
65-
0,
66-
1,
67-
0,
68-
0,
69-
0,
70-
0,
71-
1,
72-
0,
73-
0,
74-
0,
75-
0,
76-
1,
77-
'1 0 0 0 0 1 0 0 0 0 1 0 1',
78-
],
79-
tags: [],
8045
},
8146
]);
8247
});

0 commit comments

Comments
 (0)