@eturnity/eturnity_maths
Advanced tools
Comparing version 6.34.3 to 6.37.0
{ | ||
"name": "@eturnity/eturnity_maths", | ||
"version": "6.34.3", | ||
"version": "6.37.0", | ||
"author": "Eturnity Team", | ||
@@ -20,3 +20,4 @@ "main": "src/index.js", | ||
"svd-js": "^1.1.1", | ||
"uuid": "^9.0.0" | ||
"uuid": "^9.0.0", | ||
"concaveman": "^1.2.1" | ||
}, | ||
@@ -30,2 +31,2 @@ "devDependencies": { | ||
"description": "" | ||
} | ||
} |
@@ -15,3 +15,38 @@ import { | ||
import {Line} from './objects/Line' | ||
import concaveman from 'concaveman' | ||
export function getConcaveOutline(selectedPanels,onPanelOutline){ | ||
const points = selectedPanels.reduce((acc, cur) => { | ||
acc.push(...cur.outline.map((p) => [p.x, p.y])) | ||
return acc | ||
}, []) | ||
let AB = getDistanceBetweenPoints(onPanelOutline[0], onPanelOutline[1]) | ||
let AD = getDistanceBetweenPoints(onPanelOutline[0], onPanelOutline[3]) | ||
let longEdgeLength = Math.max(AB, AD) + 100 | ||
var concaveResult = concaveman(points, 1, longEdgeLength) | ||
concaveResult.pop() | ||
let moduleFieldOutline = concaveResult.map((p) => { | ||
return { | ||
x: p[0], | ||
y: p[1], | ||
z: 0 | ||
} | ||
}) | ||
//remove aligned nodes | ||
moduleFieldOutline=simplifyOutline(moduleFieldOutline) | ||
return moduleFieldOutline | ||
} | ||
export function simplifyOutline(initialOutline){ | ||
const simplifiedOutline=[] | ||
initialOutline.forEach((p, k, outline) => { | ||
let len = outline.length | ||
let A = outline[(k - 1 + len) % len] | ||
let B = outline[(k + 1) % len] | ||
let M = outline[k % len] | ||
if (!isInsideEdge2D(M, A, B)) { | ||
simplifiedOutline.push(M) | ||
} | ||
}) | ||
return simplifiedOutline | ||
} | ||
export function getSnapedValue(value, snaps, tolerance) { | ||
@@ -18,0 +53,0 @@ let closeSnapsItem = snaps.reduce( |
import { | ||
multiplyVector | ||
} from '../../vector' | ||
import {getMarginPoint} from '../../geometry' | ||
import {getMarginPoint,isClockWise} from '../../geometry' | ||
import {calculateBestFittingPlanePolygon} from './updateComputedGeometryPolygon' | ||
//update and calculate margins for all polygon | ||
@@ -110,1 +111,33 @@ export function updateMarginsOutline(state){ | ||
} | ||
export function getOutterOutlineWithConstantMargin(outline,margin){ | ||
const isClockwise = isClockWise(outline) | ||
const { | ||
projectedOutline, | ||
maximumGap, | ||
normalVector, | ||
meanPoint, | ||
incline, | ||
direction | ||
} = calculateBestFittingPlanePolygon(outline) | ||
let clockwiseNormalVector=normalVector | ||
if(isClockwise){ | ||
clockwiseNormalVector=multiplyVector(-1,clockwiseNormalVector) | ||
} | ||
//outterOutline is the outline close to the wall | ||
const outterOutline=[] | ||
const length=outline.length | ||
for(let index=0;index<length;index++){ | ||
const B=projectedOutline[index] | ||
//A,B,C three consecutive points on the polygon. | ||
//n is a vector in the plan normal to AB of length margin[A] directed towards the inside | ||
//m is a vector in the plan normal to BC of length margin[B] directed towards the inside | ||
//K is the margin outline linked with B | ||
const A=projectedOutline[(index-1+length)%length] | ||
const C=projectedOutline[(index+1)%length] | ||
//filling the margins values if not initiated. | ||
let K=getMarginPoint(A,B,C,margin,margin,clockwiseNormalVector) | ||
outterOutline.push(K) | ||
} | ||
return outterOutline | ||
} |
@@ -11,3 +11,4 @@ import { | ||
isClockWise, | ||
calculateArea | ||
calculateArea, | ||
getConcaveOutline | ||
} from '../../geometry' | ||
@@ -77,3 +78,14 @@ import { maximumGapLimit } from '../../config' | ||
polygon=updateMarginOutlinePolygon(polygon) | ||
if(polygon.layer=="moduleField"){ | ||
let trimedOutline=[] | ||
if(polygon.panels.length>0){ | ||
trimedOutline = getConcaveOutline(polygon.panels,polygon.panels[0].outline) | ||
trimedOutline = trimedOutline.map(p=>{return{ | ||
x:p.x, | ||
y:p.y, | ||
z:verticalProjectionOnPlane(p,polygon.roof.normalVector,polygon.roof.flatOutline[0]).z | ||
}}) | ||
} | ||
polygon.trimedOutline = trimedOutline | ||
} | ||
return polygon | ||
@@ -80,0 +92,0 @@ } |
102151
3177
5
+ Addedconcaveman@^1.2.1
+ Addedconcaveman@1.2.1(transitive)
+ Addedpoint-in-polygon@1.1.0(transitive)
+ Addedquickselect@2.0.0(transitive)
+ Addedrbush@3.0.1(transitive)
+ Addedrobust-predicates@2.0.4(transitive)
+ Addedtinyqueue@2.0.3(transitive)