@eturnity/eturnity_maths 6.34.3 → 6.37.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eturnity/eturnity_maths",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.37.0",
|
|
4
4
|
"author": "Eturnity Team",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"lodash": "^4.17.21",
|
|
18
18
|
"planar-face-discovery": "^2.0.7",
|
|
19
19
|
"svd-js": "^1.1.1",
|
|
20
|
-
"uuid": "^9.0.0"
|
|
20
|
+
"uuid": "^9.0.0",
|
|
21
|
+
"concaveman": "^1.2.1"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@babel/core": "^7.21.4",
|
|
@@ -26,4 +27,4 @@
|
|
|
26
27
|
"jest": "^29.5.0"
|
|
27
28
|
},
|
|
28
29
|
"description": ""
|
|
29
|
-
}
|
|
30
|
+
}
|
package/src/geometry.js
CHANGED
|
@@ -12,7 +12,42 @@ import {addVector,
|
|
|
12
12
|
normalizeVector} from './vector'
|
|
13
13
|
import {Point} from './objects/Point'
|
|
14
14
|
import {Line} from './objects/Line'
|
|
15
|
+
import concaveman from 'concaveman'
|
|
15
16
|
|
|
17
|
+
export function getConcaveOutline(selectedPanels,onPanelOutline){
|
|
18
|
+
const points = selectedPanels.reduce((acc, cur) => {
|
|
19
|
+
acc.push(...cur.outline.map((p) => [p.x, p.y]))
|
|
20
|
+
return acc
|
|
21
|
+
}, [])
|
|
22
|
+
let AB = getDistanceBetweenPoints(onPanelOutline[0], onPanelOutline[1])
|
|
23
|
+
let AD = getDistanceBetweenPoints(onPanelOutline[0], onPanelOutline[3])
|
|
24
|
+
let longEdgeLength = Math.max(AB, AD) + 100
|
|
25
|
+
var concaveResult = concaveman(points, 1, longEdgeLength)
|
|
26
|
+
concaveResult.pop()
|
|
27
|
+
let moduleFieldOutline = concaveResult.map((p) => {
|
|
28
|
+
return {
|
|
29
|
+
x: p[0],
|
|
30
|
+
y: p[1],
|
|
31
|
+
z: 0
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
//remove aligned nodes
|
|
35
|
+
moduleFieldOutline=simplifyOutline(moduleFieldOutline)
|
|
36
|
+
return moduleFieldOutline
|
|
37
|
+
}
|
|
38
|
+
export function simplifyOutline(initialOutline){
|
|
39
|
+
const simplifiedOutline=[]
|
|
40
|
+
initialOutline.forEach((p, k, outline) => {
|
|
41
|
+
let len = outline.length
|
|
42
|
+
let A = outline[(k - 1 + len) % len]
|
|
43
|
+
let B = outline[(k + 1) % len]
|
|
44
|
+
let M = outline[k % len]
|
|
45
|
+
if (!isInsideEdge2D(M, A, B)) {
|
|
46
|
+
simplifiedOutline.push(M)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
return simplifiedOutline
|
|
50
|
+
}
|
|
16
51
|
export function getSnapedValue(value, snaps, tolerance) {
|
|
17
52
|
let closeSnapsItem = snaps.reduce(
|
|
18
53
|
(acc, cur) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
multiplyVector
|
|
3
3
|
} from '../../vector'
|
|
4
|
-
import {getMarginPoint} from '../../geometry'
|
|
4
|
+
import {getMarginPoint,isClockWise} from '../../geometry'
|
|
5
|
+
import {calculateBestFittingPlanePolygon} from './updateComputedGeometryPolygon'
|
|
5
6
|
//update and calculate margins for all polygon
|
|
6
7
|
export function updateMarginsOutline(state){
|
|
7
8
|
state.polygons.forEach(polygon=>{
|
|
@@ -107,3 +108,35 @@ export function getObstacleMarginOutline(polygon){
|
|
|
107
108
|
}
|
|
108
109
|
return polygon
|
|
109
110
|
}
|
|
111
|
+
|
|
112
|
+
export function getOutterOutlineWithConstantMargin(outline,margin){
|
|
113
|
+
const isClockwise = isClockWise(outline)
|
|
114
|
+
const {
|
|
115
|
+
projectedOutline,
|
|
116
|
+
maximumGap,
|
|
117
|
+
normalVector,
|
|
118
|
+
meanPoint,
|
|
119
|
+
incline,
|
|
120
|
+
direction
|
|
121
|
+
} = calculateBestFittingPlanePolygon(outline)
|
|
122
|
+
let clockwiseNormalVector=normalVector
|
|
123
|
+
if(isClockwise){
|
|
124
|
+
clockwiseNormalVector=multiplyVector(-1,clockwiseNormalVector)
|
|
125
|
+
}
|
|
126
|
+
//outterOutline is the outline close to the wall
|
|
127
|
+
const outterOutline=[]
|
|
128
|
+
const length=outline.length
|
|
129
|
+
for(let index=0;index<length;index++){
|
|
130
|
+
const B=projectedOutline[index]
|
|
131
|
+
//A,B,C three consecutive points on the polygon.
|
|
132
|
+
//n is a vector in the plan normal to AB of length margin[A] directed towards the inside
|
|
133
|
+
//m is a vector in the plan normal to BC of length margin[B] directed towards the inside
|
|
134
|
+
//K is the margin outline linked with B
|
|
135
|
+
const A=projectedOutline[(index-1+length)%length]
|
|
136
|
+
const C=projectedOutline[(index+1)%length]
|
|
137
|
+
//filling the margins values if not initiated.
|
|
138
|
+
let K=getMarginPoint(A,B,C,margin,margin,clockwiseNormalVector)
|
|
139
|
+
outterOutline.push(K)
|
|
140
|
+
}
|
|
141
|
+
return outterOutline
|
|
142
|
+
}
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
inclineWithNormalVector,
|
|
9
9
|
directionWithNormalVector,
|
|
10
10
|
isClockWise,
|
|
11
|
-
calculateArea
|
|
11
|
+
calculateArea,
|
|
12
|
+
getConcaveOutline
|
|
12
13
|
} from '../../geometry'
|
|
13
14
|
import { maximumGapLimit } from '../../config'
|
|
14
15
|
import { SVD } from 'svd-js'
|
|
@@ -73,7 +74,18 @@ export function updateComputedGeometryPolygon(polygon) {
|
|
|
73
74
|
polygon.area=calculateArea(polygon.flatOutline)/1000000
|
|
74
75
|
polygon.isClockwise = isClockWise(polygon.outline)
|
|
75
76
|
polygon=updateMarginOutlinePolygon(polygon)
|
|
76
|
-
|
|
77
|
+
if(polygon.layer=="moduleField"){
|
|
78
|
+
let trimedOutline=[]
|
|
79
|
+
if(polygon.panels.length>0){
|
|
80
|
+
trimedOutline = getConcaveOutline(polygon.panels,polygon.panels[0].outline)
|
|
81
|
+
trimedOutline = trimedOutline.map(p=>{return{
|
|
82
|
+
x:p.x,
|
|
83
|
+
y:p.y,
|
|
84
|
+
z:verticalProjectionOnPlane(p,polygon.roof.normalVector,polygon.roof.flatOutline[0]).z
|
|
85
|
+
}})
|
|
86
|
+
}
|
|
87
|
+
polygon.trimedOutline = trimedOutline
|
|
88
|
+
}
|
|
77
89
|
return polygon
|
|
78
90
|
}
|
|
79
91
|
|