@eturnity/eturnity_maths
Advanced tools
Comparing version 6.42.1-EPDM-7379.1 to 6.42.1-EPDM-7379.2
{ | ||
"name": "@eturnity/eturnity_maths", | ||
"version": "6.42.1-EPDM-7379.1", | ||
"version": "6.42.1-EPDM-7379.2", | ||
"author": "Eturnity Team", | ||
@@ -30,2 +30,2 @@ "main": "src/index.js", | ||
"description": "" | ||
} | ||
} |
import { | ||
meanVector, | ||
substractVector, | ||
multiplyVector | ||
multiplyVector, | ||
addVector | ||
} from '../../vector' | ||
@@ -12,3 +13,7 @@ import { | ||
calculateArea, | ||
getConcaveOutline | ||
getConcaveOutline, | ||
normalizedVectorTowardInsideAngle, | ||
normalizeVector, | ||
isAlmostSamePoint2D, | ||
getDistanceBetweenPoints | ||
} from '../../geometry' | ||
@@ -60,2 +65,6 @@ import { maximumGapLimit } from '../../config' | ||
} | ||
if(isAlmostSamePoint2D(polygon.outline[0],polygon.outline[polygon.outline.length-1],10)){ | ||
polygon.outline.pop() | ||
} | ||
polygon.outline = calculateValidOutlineFromPolygon(polygon.outline) | ||
const { | ||
@@ -93,2 +102,29 @@ projectedOutline, | ||
} | ||
export function calculateValidOutlineFromPolygon(outline){ | ||
//check if two nodes are same | ||
const nodeIndexToSplit=[] | ||
for(let k=0;k<outline.length-1;k++){ | ||
for(let i=k+1;i<outline.length;i++){ | ||
if(isAlmostSamePoint2D(outline[k],outline[i],100)){ | ||
nodeIndexToSplit.push([k,i]) | ||
} | ||
} | ||
} | ||
for(let coupleToSplit of nodeIndexToSplit){ | ||
const A = outline[(coupleToSplit[0]-1+outline.length)%outline.length] | ||
const B = outline[coupleToSplit[0]] | ||
const C = outline[(coupleToSplit[0]+1)%outline.length] | ||
let v = normalizedVectorTowardInsideAngle(A,B,C) | ||
// let v0=normalizeVector(substractVector()) | ||
outline[coupleToSplit[0]] = { | ||
...addVector(multiplyVector(-50,v),B), | ||
z:outline[coupleToSplit[0]].z | ||
} | ||
outline[coupleToSplit[1]] = { | ||
...addVector(multiplyVector(50,v),B), | ||
z:outline[coupleToSplit[1]].z | ||
} | ||
} | ||
return outline | ||
} | ||
@@ -95,0 +131,0 @@ export function calculateBestFittingPlanePolygon(fullOutline) { |
@@ -64,3 +64,2 @@ import { PlanarFaceTree } from 'planar-face-discovery' | ||
) { | ||
//if(isClosedContructionPolyline){ | ||
constructionPolyline.outline.forEach((p) => { | ||
@@ -86,3 +85,2 @@ let supportRoof = roofs.find((roof) => isInsidePolygon(p, roof.outline)) | ||
//3. generate all edges not cut, those cut and those from construction polyline | ||
const edgeList = getEdgeList( | ||
@@ -398,3 +396,3 @@ nodeList, | ||
if (cycleTree.cycle.length) { | ||
//cycles.push(cycleTree.cycle) | ||
cycles.push(cycleTree.cycle) | ||
} | ||
@@ -422,3 +420,2 @@ return cycles | ||
} | ||
let outlines = cycles | ||
@@ -425,0 +422,0 @@ .map((cycle) => { |
106189
3297