From 5ff1f4b91096410ca4a4b405fc3be1c76dbfe112 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 24 四月 2024 16:06:06 +0800
Subject: [PATCH] #

---
 src/utils/common.js |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/utils/common.js b/src/utils/common.js
index 2ace608..5c5c8df 100644
--- a/src/utils/common.js
+++ b/src/utils/common.js
@@ -1,4 +1,5 @@
 import * as THREE from 'three';
+import { REAL_COMPARE_MAP_SCALE, REAL_COMPARE_MAP_OFFSET_X, REAL_COMPARE_MAP_OFFSET_Z } from '../config/setting'
 
 export const isNullOfUndefined = (param) => {
     if (null === param || undefined === param) {
@@ -19,8 +20,21 @@
 }
 
 export const rotationParseNum = (num) => {
-    return num * Math.PI / 180;
+    const normalizedDegrees = num % 360;
+    return normalizedDegrees * Math.PI / 180;
 }
+
+export const minDiffTheta = (originTheta, targetTheta) => {
+    return (targetTheta - originTheta > 180) ? targetTheta - 360 : targetTheta;
+}
+
+export const calculateMappedPosition = (realPos) => {
+    return [
+        realPos[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
+        realPos[1],
+        realPos[2] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z
+    ];
+};
 
 export const setShadow = (obj) => {
     obj.castShadow = true;
@@ -42,4 +56,24 @@
             setColor(child);
         });
     }
-};
\ No newline at end of file
+};
+
+export const deepEqual = (obj1, obj2) => {
+    if (obj1 === obj2) {
+        return true;
+    }
+    if (typeof obj1 !== "object" || obj1 === null || typeof obj2 !== "object" || obj2 === null) {
+        return false;
+    }
+    var keys1 = Object.keys(obj1);
+    var keys2 = Object.keys(obj2);
+    if (keys1.length !== keys2.length) {
+        return false;
+    }
+    for (var key of keys1) {
+        if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {
+            return false;
+        }
+    }
+    return true;
+}
\ No newline at end of file

--
Gitblit v1.9.1