@eturnity/eturnity_maths
Advanced tools
Comparing version 6.34.3-3d-qa-6.37 to 6.34.3-3d-qa-6.37.0.0
{ | ||
"name": "@eturnity/eturnity_maths", | ||
"version": "6.34.3-3d-qa-6.37", | ||
"version": "6.34.3-3d-qa-6.37.0.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" | ||
}, | ||
@@ -23,0 +24,0 @@ "devDependencies": { |
@@ -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) { | ||
@@ -73,10 +108,2 @@ 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 | ||
} | ||
@@ -83,0 +110,0 @@ export function getDegree(H, I, J) { |
@@ -5,4 +5,2 @@ | ||
translate2D, | ||
verticalProjectionOnPlane, | ||
get3DDistanceBetweenPoints | ||
} from '../geometry' | ||
@@ -38,17 +36,7 @@ import { v4 as uuidv4 } from 'uuid' | ||
let pxRadius = this.radius / canvasContext.mmPerPx | ||
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) | ||
return Math.abs(getDistanceBetweenPoints(point, pxCenter) - pxRadius) | ||
} | ||
getProjectedPoint(point) { | ||
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) { | ||
let distance = getDistanceBetweenPoints(point, this.center) | ||
if (distance == 0) { | ||
console.error("can't project center to cercle", this) | ||
@@ -55,0 +43,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 | ||
} |
101731
3164
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)