@eturnity/eturnity_maths 6.37.0 → 6.38.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "6.37.0",
3
+ "version": "6.38.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
package/src/geometry.js CHANGED
@@ -104,6 +104,14 @@ 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
+ }
107
115
 
108
116
  export function getDegree(H, I, J) {
109
117
  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 = {x:0,y:0}){
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}
@@ -2,6 +2,8 @@
2
2
  import {
3
3
  getDistanceBetweenPoints,
4
4
  translate2D,
5
+ verticalProjectionOnPlane,
6
+ get3DDistanceBetweenPoints
5
7
  } from '../geometry'
6
8
  import { v4 as uuidv4 } from 'uuid'
7
9
  import {Point} from './Point'
@@ -32,11 +34,21 @@ export class Circle {
32
34
  const toCanvasRef = canvasContext.toCanvasRef
33
35
  let pxCenter = toCanvasRef(this.center)
34
36
  let pxRadius = this.radius / canvasContext.mmPerPx
35
- return Math.abs(getDistanceBetweenPoints(point, pxCenter) - pxRadius)
37
+ if(this.normalVector){
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)
36
43
  }
37
44
  getProjectedPoint(point) {
38
- let distance = getDistanceBetweenPoints(point, this.center)
39
- if (distance == 0) {
45
+ if(this.normalVector){
46
+ point.z=verticalProjectionOnPlane(point,this.normalVector,this.center).z
47
+ }else{
48
+ point.z=this.center.z
49
+ }
50
+ let distance = get3DDistanceBetweenPoints(point, this.center)
51
+ if (distance == 0) {
40
52
  console.error("can't project center to cercle", this)
41
53
  return null
42
54
  }
@@ -1,6 +1,7 @@
1
1
 
2
2
  import {
3
3
  getDistanceBetweenPoints,
4
+ get3DDistanceBetweenPoints,
4
5
  getPointOnLine,
5
6
  isSamePoint3D,
6
7
  translate2D,
@@ -40,8 +41,8 @@ export class Line {
40
41
  canvasContext.mmPerPx
41
42
  )
42
43
  }
43
- mmLength(canvasContext) {
44
- return getDistanceBetweenPoints(this.outline[0], this.outline[1])
44
+ mmLength() {
45
+ return get3DDistanceBetweenPoints(this.outline[0], this.outline[1])
45
46
  }
46
47
 
47
48
  getMidPoint() {
@@ -26,6 +26,7 @@ export class Polygon {
26
26
  this.highlight = false
27
27
  this.visible = true
28
28
  this.heightReference = 0
29
+ this.priority = 0
29
30
  this.margins = {
30
31
  isSameMargin: true,
31
32
  sameMargin: 200,