@eturnity/eturnity_maths 6.50.1 → 7.2.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.50.1",
3
+ "version": "7.2.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
package/src/geometry.js CHANGED
@@ -10,6 +10,7 @@ import {addVector,
10
10
  meanVector,
11
11
  vectorLength,
12
12
  normalizeVector} from './vector'
13
+ import {inverse3x3matrix,multiplyMatrices} from './matrix'
13
14
  import {Point} from './objects/Point'
14
15
  import {Line} from './objects/Line'
15
16
  import concaveman from 'concaveman'
@@ -91,6 +92,23 @@ export function getParallelLinePassingByPoint(A, B, C) {
91
92
  const D = new Point(C.x + B.x - A.x, C.y + B.y - A.y)
92
93
  return new Line(C, D, '')
93
94
  }
95
+
96
+ export function getDataAboutTwo3DLines(A,u,B,v){
97
+ let w=crossProduct(u,v)
98
+ let m=[
99
+ [u.x,v.x,w.x],
100
+ [u.y,v.y,w.y],
101
+ [u.z,v.z,w.z]
102
+ ]
103
+ let mInv=inverse3x3matrix(m)
104
+ let AB=substractVector(B,A)
105
+ let [t1,t2,t3] = multiplyMatrices(mInv,[[AB.x],[AB.y],[AB.z]])
106
+ let M=addVector(A,multiplyVector(t1,u))
107
+ let N=addVector(B,multiplyVector(t2,v))
108
+ let distance=get3DDistanceBetweenPoints(M,N)
109
+ return {m,mInv,M,N,A,B,u,v,w,distance,t1,t2,t3}
110
+
111
+ }
94
112
  export function vectorFromAngleInDegCanvas(angle) {
95
113
  return {
96
114
  x: Math.sin((angle * Math.PI) / 180),
@@ -104,6 +122,7 @@ export function getDistanceBetweenPoints(firstPoint, secondPoint) {
104
122
  )
105
123
  return distance
106
124
  }
125
+
107
126
  export function get3DDistanceBetweenPoints(firstPoint, secondPoint) {
108
127
  const distance = Math.hypot(
109
128
  firstPoint.x - secondPoint.x,
@@ -143,6 +162,9 @@ export function get3DDistanceBetweenPoints(firstPoint, secondPoint) {
143
162
  export function isSamePoint3D(A, B) {
144
163
  return A.x == B.x && A.y == B.y && A.z == B.z
145
164
  }
165
+ export function isAlmostSamePoint3D(A, B, tolerance) {
166
+ return Math.abs(A.x - B.x) < tolerance && Math.abs(A.y - B.y) < tolerance && Math.abs(A.z - B.z) < tolerance
167
+ }
146
168
  export function isSamePoint2D(A, B) {
147
169
  return A.x == B.x && A.y == B.y
148
170
  }
@@ -172,6 +194,15 @@ export function get3DDistanceBetweenPoints(firstPoint, secondPoint) {
172
194
  isSamePoint3D(seg_0[0], seg_1[1]) && isSamePoint3D(seg_0[1], seg_1[0])
173
195
  return check_1 || check_2
174
196
  }
197
+ export function isAlmostSameSegment3D(seg_0, seg_1, tolerance) {
198
+ let check_1 =
199
+ isAlmostSamePoint3D(seg_0[0], seg_1[0], tolerance) &&
200
+ isAlmostSamePoint3D(seg_0[1], seg_1[1], tolerance)
201
+ let check_2 =
202
+ isAlmostSamePoint3D(seg_0[0], seg_1[1], tolerance) &&
203
+ isAlmostSamePoint3D(seg_0[1], seg_1[0], tolerance)
204
+ return check_1 || check_2
205
+ }
175
206
  export function isSameLine(AB, CD) {
176
207
  if (!AB || !CD) {
177
208
  console.error('AB or CD not defined')
@@ -600,7 +631,13 @@ export function get3DDistanceBetweenPoints(firstPoint, secondPoint) {
600
631
  const normalVector = normalizeVector(crossProduct(AB, BC))
601
632
  return normalVector
602
633
  }
603
-
634
+ export function normalVectorWithDirectionAndIncline(direction,incline){
635
+ return {
636
+ x:Math.sin(direction*Math.PI/180)*Math.sin(incline*Math.PI/180),
637
+ y:Math.cos(direction*Math.PI/180)*Math.sin(incline*Math.PI/180),
638
+ z:Math.cos(incline*Math.PI/180)
639
+ }
640
+ }
604
641
  export function inclineWithNormalVector(normalVector) {
605
642
  const angleRad = Math.acos(dotProduct(normalVector, { x: 0, y: 0, z: 1 }))
606
643
  const angleDeg = (angleRad * 180) / Math.PI
@@ -188,7 +188,8 @@ export class Polygon {
188
188
  roof_margins_mm: margins_roof_mm,
189
189
  roof_slope_degrees: this.incline,
190
190
  roof_orientation_degrees: this.direction,
191
- roof_name: this.name
191
+ roof_name: this.name,
192
+ shading_data: this.shadingData ? this.shadingData : undefined
192
193
  }
193
194
  } else if (this.layer == 'obstacle') {
194
195
  const margins_obstacle_mm = this.margins.isSameMargin