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())); 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; if (v1.getX() < 0 && v1.getY() < 0) {
public double dot(Vector2d v) { return dot(v.x, v.y); }
public double dot(float x, float y) { return dot((double) x, (double) y); }
public double dot(Vector2d v) { return dot(v.x, v.y); }
public double dot(float x, float y) { return dot((double) x, (double) y); }
public Vector2d project(double x, double y) { final double lengthSquared = x * x + y * y; if (Math.abs(lengthSquared) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot project onto the zero vector"); } final double a = dot(x, y) / lengthSquared; return new Vector2d(a * x, a * y); }
public Vector2d project(double x, double y) { final double lengthSquared = x * x + y * y; if (Math.abs(lengthSquared) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot project onto the zero vector"); } final double a = dot(x, y) / lengthSquared; return new Vector2d(a * x, a * y); }
/** * Creates a new complex from the angle defined from the first to the second vector. * * @param from The first vector * @param to The second vector * @return The complex defined by the angle between the vectors */ public static Complexd fromRotationTo(Vector2d from, Vector2d to) { return fromAngleRad(TrigMath.acos(from.dot(to) / (from.length() * to.length()))); }
/** * Creates a new complex from the angle defined from the first to the second vector. * * @param from The first vector * @param to The second vector * @return The complex defined by the angle between the vectors */ public static Complexd fromRotationTo(Vector2d from, Vector2d to) { return fromAngleRad(TrigMath.acos(from.dot(to) / (from.length() * to.length()))); }
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())); 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; if (v1.getX() < 0 && v1.getY() < 0)