From 902a0f61198cd25a35f5c228badd9fffdaada7cd Mon Sep 17 00:00:00 2001 From: MistPhizzle Date: Thu, 12 Jun 2014 19:37:51 -0400 Subject: [PATCH] Vector Methods (Comes from orion304's original plugin, credit goes to him) --- .../projectkorra/ProjectKorra/Methods.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/com/projectkorra/ProjectKorra/Methods.java b/src/com/projectkorra/ProjectKorra/Methods.java index 020153d1..a56d6ba8 100644 --- a/src/com/projectkorra/ProjectKorra/Methods.java +++ b/src/com/projectkorra/ProjectKorra/Methods.java @@ -378,6 +378,34 @@ public class Methods { } return true; } + + public static Vector rotateVectorAroundVector(Vector axis, Vector rotator, + double degrees) { + double angle = Math.toRadians(degrees); + Vector rotation = axis.clone(); + Vector rotate = rotator.clone(); + rotation = rotation.normalize(); + + Vector thirdaxis = rotation.crossProduct(rotate).normalize() + .multiply(rotate.length()); + + return rotate.multiply(Math.cos(angle)).add( + thirdaxis.multiply(Math.sin(angle))); + + // return new Vector(x, z, y); + } + + public static Vector getOrthogonalVector(Vector axis, double degrees, + double length) { + + Vector ortho = new Vector(axis.getY(), -axis.getX(), 0); + ortho = ortho.normalize(); + ortho = ortho.multiply(length); + + return rotateVectorAroundVector(axis, ortho, degrees); + + } + public static boolean isWeapon(Material mat) { if (mat == null) return false; if (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE