aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2021-10-02 15:30:51 +0900
committersyeyoung <cyoung06@naver.com>2021-10-02 15:33:33 +0900
commitf818e42c6c21ed6b2d7993dca87e6cd52f3d5251 (patch)
tree250f7979a82e146b61bcbcc2f4d9fd6b57bee911 /src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java
parent07f74480447495e6cd42237e4740fb082cb4b821 (diff)
downloadSkyblock-Dungeons-Guide-f818e42c6c21ed6b2d7993dca87e6cd52f3d5251.tar.gz
Skyblock-Dungeons-Guide-f818e42c6c21ed6b2d7993dca87e6cd52f3d5251.tar.bz2
Skyblock-Dungeons-Guide-f818e42c6c21ed6b2d7993dca87e6cd52f3d5251.zip
Line Properties for each pathfind context
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java
index 8f13dd8a..59eaa866 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java
@@ -18,6 +18,12 @@
package kr.syeyoung.dungeonsguide.utils;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.ActiveRenderInfo;
+import net.minecraft.util.Vec3;
+
import javax.vecmath.Vector2d;
public class VectorUtils {
@@ -30,4 +36,18 @@ public class VectorUtils {
public static Vector2d rotateClockwise(Vector2d vector2d) {
return new Vector2d(-vector2d.y, vector2d.x);
}
+
+ @Data @AllArgsConstructor
+ public static class ProjectionResult {
+ private float x;
+ private float y;
+ private boolean back;
+ }
+
+ public static double distSquared(Vec3 lookVec, Vec3 posVec, Vec3 objectVec) {
+ Vec3 v = objectVec.subtract(posVec);
+ double t = v.dotProduct(lookVec);
+ Vec3 p = posVec.addVector(lookVec.xCoord * t, lookVec.yCoord * t, lookVec.zCoord * t);
+ return p.squareDistanceTo(objectVec) / p.squareDistanceTo(posVec);
+ }
}