Vector2d p1 = Vector2d.UNIT_Y.mul(eyePos.getY()); Vector2d p2 = new Vector2d(distance, targetPos.getY()); Vector2d v1 = p2.sub(p1); Vector2d v2 = Vector2d.UNIT_X.mul(distance); final double pitchRad = Math.acos(v1.dot(v2) / (v1.length() * v2.length())); final double pitchDeg = pitchRad * 180 / Math.PI * (-v1.getY() / Math.abs(v1.getY())); p2 = xz2; v1 = p2.sub(p1); v2 = Vector2d.UNIT_Y.mul(v1.getY()); double yawRad = Math.acos(v1.dot(v2) / (v1.length() * v2.length())); double yawDeg = yawRad * 180 / Math.PI;
public Vector2d mul(float x, float y) { return mul((double) x, (double) y); }
@Override public Vector2d mul(double a) { return mul(a, a); }
@Override public Vector2d mul(double a) { return mul(a, a); }
public Vector2d mul(float a) { return mul((double) a); }
public Vector2d mul(float a) { return mul((double) a); }
public Vector2d mul(float x, float y) { return mul((double) x, (double) y); }
public Vector2d mul(Vector2d v) { return mul(v.x, v.y); }
public Vector2d mul(Vector2d v) { return mul(v.x, v.y); }
/** * Calculates the linear interpolation between a and b with the given percent * * @param a The first know value * @param b The second know value * @param percent The percent * @return the interpolated vector */ public static Vector2d lerp(Vector2d a, Vector2d b, double percent) { return a.mul(1 - percent).add(b.mul(percent)); }
/** * Calculates the linear interpolation between a and b with the given percent * * @param a The first know value * @param b The second know value * @param percent The percent * @return the interpolated vector */ public static Vector2d lerp(Vector2d a, Vector2d b, double percent) { return a.mul(1 - percent).add(b.mul(percent)); }
Vector2d p1 = Vector2d.UNIT_Y.mul(eyePos.getY()); Vector2d p2 = new Vector2d(distance, targetPos.getY()); Vector2d v1 = p2.sub(p1); Vector2d v2 = Vector2d.UNIT_X.mul(distance); double pitchRad = Math.acos(v1.dot(v2) / (v1.length() * v2.length())); double pitchDeg = pitchRad * 180 / Math.PI * (-v1.getY() / Math.abs(v1.getY())); p2 = xz2; v1 = p2.sub(p1); v2 = Vector2d.UNIT_Y.mul(v1.getY()); double yawRad = Math.acos(v1.dot(v2) / (v1.length() * v2.length())); double yawDeg = yawRad * 180 / Math.PI;