@eturnity/eturnity_maths 6.44.1 → 6.46.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.44.1",
3
+ "version": "6.46.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  meanVector,
3
3
  substractVector,
4
- multiplyVector
4
+ multiplyVector,
5
+ addVector
5
6
  } from '../../vector'
6
7
  import {
7
8
  verticalProjectionOnPlane,
@@ -9,7 +10,11 @@ import {
9
10
  directionWithNormalVector,
10
11
  isClockWise,
11
12
  calculateArea,
12
- getConcaveOutline
13
+ getConcaveOutline,
14
+ normalizedVectorTowardInsideAngle,
15
+ normalizeVector,
16
+ isAlmostSamePoint2D,
17
+ getDistanceBetweenPoints
13
18
  } from '../../geometry'
14
19
  import { maximumGapLimit } from '../../config'
15
20
  import { SVD } from 'svd-js'
@@ -56,6 +61,10 @@ export function updateComputedGeometryPolygon(polygon) {
56
61
  if(!['roof','obstacle','moduleField'].includes(polygon.layer)){
57
62
  return polygon
58
63
  }
64
+ if(isAlmostSamePoint2D(polygon.outline[0],polygon.outline[polygon.outline.length-1],10)){
65
+ polygon.outline.pop()
66
+ }
67
+ polygon.outline = calculateValidOutlineFromPolygon(polygon.outline)
59
68
  const {
60
69
  projectedOutline,
61
70
  maximumGap,
@@ -88,6 +97,33 @@ export function updateComputedGeometryPolygon(polygon) {
88
97
  }
89
98
  return polygon
90
99
  }
100
+ export function calculateValidOutlineFromPolygon(outline){
101
+ //check if two nodes are same
102
+ const nodeIndexToSplit=[]
103
+ for(let k=0;k<outline.length-1;k++){
104
+ for(let i=k+1;i<outline.length;i++){
105
+ if(isAlmostSamePoint2D(outline[k],outline[i],100)){
106
+ nodeIndexToSplit.push([k,i])
107
+ }
108
+ }
109
+ }
110
+ for(let coupleToSplit of nodeIndexToSplit){
111
+ const A = outline[(coupleToSplit[0]-1+outline.length)%outline.length]
112
+ const B = outline[coupleToSplit[0]]
113
+ const C = outline[(coupleToSplit[0]+1)%outline.length]
114
+ let v = normalizedVectorTowardInsideAngle(A,B,C)
115
+ // let v0=normalizeVector(substractVector())
116
+ outline[coupleToSplit[0]] = {
117
+ ...addVector(multiplyVector(-50,v),B),
118
+ z:outline[coupleToSplit[0]].z
119
+ }
120
+ outline[coupleToSplit[1]] = {
121
+ ...addVector(multiplyVector(50,v),B),
122
+ z:outline[coupleToSplit[1]].z
123
+ }
124
+ }
125
+ return outline
126
+ }
91
127
 
92
128
  export function calculateBestFittingPlanePolygon(fullOutline) {
93
129
  if (fullOutline.length < 3) {
@@ -61,7 +61,6 @@ export function splitPolygons(
61
61
  roofs,
62
62
  isClosedContructionPolyline
63
63
  ) {
64
- //if(isClosedContructionPolyline){
65
64
  constructionPolyline.outline.forEach((p) => {
66
65
  let supportRoof = roofs.find((roof) => isInsidePolygon(p, roof.outline))
67
66
  if (supportRoof) {
@@ -82,7 +81,6 @@ export function splitPolygons(
82
81
  //2. gather all nodes+intersection in a list[[x,y],[x,y]]
83
82
  const nodeList = getNodeList(intersections, roofEdge, constructionPolyline)
84
83
  //3. generate all edges not cut, those cut and those from construction polyline
85
-
86
84
  const edgeList = getEdgeList(
87
85
  nodeList,
88
86
  intersections,
@@ -393,7 +391,7 @@ function forestRecursion(cycleTree) {
393
391
  return done
394
392
  }, [])
395
393
  if (cycleTree.cycle.length) {
396
- //cycles.push(cycleTree.cycle)
394
+ cycles.push(cycleTree.cycle)
397
395
  }
398
396
  return cycles
399
397
  } else {
@@ -416,7 +414,6 @@ export function getOutlineList(nodeList, edgeList, roofs = []) {
416
414
  let cycleArray = forestRecursion(cycleTree)
417
415
  cycles.push(...cycleArray)
418
416
  }
419
-
420
417
  let outlines = cycles
421
418
  .map((cycle) => {
422
419
  return cycle.map((index) => {