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) {
@Override public Vector2d normalize() { final double length = length(); if (Math.abs(length) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot normalize the zero vector"); } return new Vector2d(x / length, y / length); }
@Override public Vector2d normalize() { final double length = length(); if (Math.abs(length) < GenericMath.DBL_EPSILON) { throw new ArithmeticException("Cannot normalize the zero vector"); } return new Vector2d(x / length, y / 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()))); }
/** * 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)