From f818e42c6c21ed6b2d7993dca87e6cd52f3d5251 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sat, 2 Oct 2021 15:30:51 +0900 Subject: Line Properties for each pathfind context --- .../kr/syeyoung/dungeonsguide/utils/VectorUtils.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java') 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); + } } -- cgit