@eturnity/eturnity_maths
Advanced tools
Comparing version 6.34.3 to 6.37.0-3d-qa-6.38.0
{ | ||
"name": "@eturnity/eturnity_maths", | ||
"version": "6.34.3", | ||
"version": "6.37.0-3d-qa-6.38.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,onePanelOutline){ | ||
const points = selectedPanels.reduce((acc, cur) => { | ||
acc.push(...cur.outline.map((p) => [p.x, p.y])) | ||
return acc | ||
}, []) | ||
let AB = getDistanceBetweenPoints(onePanelOutline[0], onePanelOutline[1]) | ||
let AD = getDistanceBetweenPoints(onePanelOutline[0], onePanelOutline[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) { | ||
@@ -73,2 +108,10 @@ let closeSnapsItem = snaps.reduce( | ||
} | ||
export function get3DDistanceBetweenPoints(firstPoint, secondPoint) { | ||
const distance = Math.hypot( | ||
firstPoint.x - secondPoint.x, | ||
firstPoint.y - secondPoint.y, | ||
firstPoint.z - secondPoint.z | ||
) | ||
return distance | ||
} | ||
@@ -75,0 +118,0 @@ export function getDegree(H, I, J) { |
@@ -5,2 +5,4 @@ | ||
translate2D, | ||
verticalProjectionOnPlane, | ||
get3DDistanceBetweenPoints | ||
} from '../geometry' | ||
@@ -36,7 +38,17 @@ import { v4 as uuidv4 } from 'uuid' | ||
let pxRadius = this.radius / canvasContext.mmPerPx | ||
return Math.abs(getDistanceBetweenPoints(point, pxCenter) - pxRadius) | ||
if(this.normalVector){ | ||
point.z=verticalProjectionOnPlane(point,this.normalVector,this.center).z | ||
}else{ | ||
point.z=this.center.z | ||
} | ||
return Math.abs(get3DDistanceBetweenPoints(point, pxCenter) - pxRadius) | ||
} | ||
getProjectedPoint(point) { | ||
let distance = getDistanceBetweenPoints(point, this.center) | ||
if (distance == 0) { | ||
if(this.normalVector){ | ||
point.z=verticalProjectionOnPlane(point,this.normalVector,this.center).z | ||
}else{ | ||
point.z=this.center.z | ||
} | ||
let distance = get3DDistanceBetweenPoints(point, this.center) | ||
if (distance == 0) { | ||
console.error("can't project center to cercle", this) | ||
@@ -43,0 +55,0 @@ return null |
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 @@ } |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
102777
3197
5
2
+ 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)