@eturnity/eturnity_maths 6.38.0 → 6.39.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 +1 -1
- package/src/geometry.js +1 -9
- package/src/matrix.js +1 -1
- package/src/objects/Circle.js +3 -15
- package/src/objects/Line.js +2 -3
- package/src/objects/Polygon.js +0 -1
package/package.json
CHANGED
package/src/geometry.js
CHANGED
|
@@ -21,7 +21,7 @@ export function getConcaveOutline(selectedPanels,onPanelOutline){
|
|
|
21
21
|
}, [])
|
|
22
22
|
let AB = getDistanceBetweenPoints(onPanelOutline[0], onPanelOutline[1])
|
|
23
23
|
let AD = getDistanceBetweenPoints(onPanelOutline[0], onPanelOutline[3])
|
|
24
|
-
let longEdgeLength = Math.
|
|
24
|
+
let longEdgeLength = Math.min(AB, AD)
|
|
25
25
|
var concaveResult = concaveman(points, 1, longEdgeLength)
|
|
26
26
|
concaveResult.pop()
|
|
27
27
|
let moduleFieldOutline = concaveResult.map((p) => {
|
|
@@ -104,14 +104,6 @@ export function getDistanceBetweenPoints(firstPoint, secondPoint) {
|
|
|
104
104
|
)
|
|
105
105
|
return distance
|
|
106
106
|
}
|
|
107
|
-
export function get3DDistanceBetweenPoints(firstPoint, secondPoint) {
|
|
108
|
-
const distance = Math.hypot(
|
|
109
|
-
firstPoint.x - secondPoint.x,
|
|
110
|
-
firstPoint.y - secondPoint.y,
|
|
111
|
-
firstPoint.z - secondPoint.z
|
|
112
|
-
)
|
|
113
|
-
return distance
|
|
114
|
-
}
|
|
115
107
|
|
|
116
108
|
export function getDegree(H, I, J) {
|
|
117
109
|
const a = getDistanceBetweenPoints(H, I)
|
package/src/matrix.js
CHANGED
|
@@ -52,7 +52,7 @@ export function inverse3x3matrix(m) {
|
|
|
52
52
|
}
|
|
53
53
|
return product
|
|
54
54
|
}
|
|
55
|
-
export function rotateTransformation(point,angle,center
|
|
55
|
+
export function rotateTransformation(point,angle,center){
|
|
56
56
|
let rotationMatrix=[[Math.cos(angle),Math.sin(angle)],[-Math.sin(angle),Math.cos(angle)]]
|
|
57
57
|
let k=multiplyMatrices(rotationMatrix,[[point.x-center.x],[point.y-center.y]])
|
|
58
58
|
return {x:k[0][0]+center.x,y:k[1][0]+center.y}
|
package/src/objects/Circle.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
getDistanceBetweenPoints,
|
|
4
4
|
translate2D,
|
|
5
|
-
verticalProjectionOnPlane,
|
|
6
|
-
get3DDistanceBetweenPoints
|
|
7
5
|
} from '../geometry'
|
|
8
6
|
import { v4 as uuidv4 } from 'uuid'
|
|
9
7
|
import {Point} from './Point'
|
|
@@ -34,21 +32,11 @@ export class Circle {
|
|
|
34
32
|
const toCanvasRef = canvasContext.toCanvasRef
|
|
35
33
|
let pxCenter = toCanvasRef(this.center)
|
|
36
34
|
let pxRadius = this.radius / canvasContext.mmPerPx
|
|
37
|
-
|
|
38
|
-
point.z=verticalProjectionOnPlane(point,this.normalVector,this.center).z
|
|
39
|
-
}else{
|
|
40
|
-
point.z=this.center.z
|
|
41
|
-
}
|
|
42
|
-
return Math.abs(get3DDistanceBetweenPoints(point, pxCenter) - pxRadius)
|
|
35
|
+
return Math.abs(getDistanceBetweenPoints(point, pxCenter) - pxRadius)
|
|
43
36
|
}
|
|
44
37
|
getProjectedPoint(point) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}else{
|
|
48
|
-
point.z=this.center.z
|
|
49
|
-
}
|
|
50
|
-
let distance = get3DDistanceBetweenPoints(point, this.center)
|
|
51
|
-
if (distance == 0) {
|
|
38
|
+
let distance = getDistanceBetweenPoints(point, this.center)
|
|
39
|
+
if (distance == 0) {
|
|
52
40
|
console.error("can't project center to cercle", this)
|
|
53
41
|
return null
|
|
54
42
|
}
|
package/src/objects/Line.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import {
|
|
3
3
|
getDistanceBetweenPoints,
|
|
4
|
-
get3DDistanceBetweenPoints,
|
|
5
4
|
getPointOnLine,
|
|
6
5
|
isSamePoint3D,
|
|
7
6
|
translate2D,
|
|
@@ -41,8 +40,8 @@ export class Line {
|
|
|
41
40
|
canvasContext.mmPerPx
|
|
42
41
|
)
|
|
43
42
|
}
|
|
44
|
-
mmLength() {
|
|
45
|
-
return
|
|
43
|
+
mmLength(canvasContext) {
|
|
44
|
+
return getDistanceBetweenPoints(this.outline[0], this.outline[1])
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
getMidPoint() {
|