/** * Get the square of the cartesian length of this vector. */ public double vectorLengthSquared () { return this.dot(this); }
public double vectorLengthSquared () { return this.dot(this); }
/** * Get the direction one must travel from A to get to B. * * @param thetaA * The azimuth of point A * @param phiA * The polar angle of point A * @param thetaB * The azimuth of point B * @param phiB * The polar angle of point B * @return The angle from A to B, in radians, counterclockwise from due East */ public static double getAzimuth (double thetaA, double phiA, double thetaB, double phiB) { if (equal(0.0, phiA)) return -Math.PI / 2.0; if (equal(Math.PI, phiA)) return Math.PI / 2.0; Vector A = toUnitVector(thetaA, phiA); Vector B = toUnitVector(thetaB, phiB); Vector AB = A.cross(B).cross(A); Vector AN = A.cross(Z).cross(A); Vector AE = AN.cross(A); double deltaX = AB.dot(AE); double deltaY = AB.dot(AN); return Math.atan2(deltaY, deltaX); }
/** * Get the direction one must travel from A to get to B. * * @param thetaA * The azimuth of point A * @param phiA * The polar angle of point A * @param thetaB * The azimuth of point B * @param phiB * The polar angle of point B * @return The angle from A to B, in radians, counterclockwise from due East */ public static double getAzimuth (double thetaA, double phiA, double thetaB, double phiB) { if (equal(0.0, phiA)) return -Math.PI / 2.0; if (equal(Math.PI, phiA)) return Math.PI / 2.0; Vector A = toUnitVector(thetaA, phiA); Vector B = toUnitVector(thetaB, phiB); Vector AB = A.cross(B).cross(A); Vector AN = A.cross(Z).cross(A); Vector AE = AN.cross(A); double deltaX = AB.dot(AE); double deltaY = AB.dot(AN); return Math.atan2(deltaY, deltaX); }
@Override protected double getRelativeError (Position a, Position b, Position c) { Vector vA = a.getAsCartesian(); Vector vB = b.getAsCartesian(); Vector vC = c.getAsCartesian(); Vector ac = vC.subtract(vA); Vector ab = vB.subtract(vA); double lac2 = ac.vectorLengthSquared(); Vector bPerp = ab.subtract(ac.scale(ab.dot(ac)/lac2)); double lbPerp = bPerp.vectorLength(); double lac = Math.sqrt(lac2); return lbPerp/lac; }
@Override protected double getRelativeError (Position a, Position b, Position c) { Vector vA = a.getAsCartesian(); Vector vB = b.getAsCartesian(); Vector vC = c.getAsCartesian(); Vector ac = vC.subtract(vA); Vector ab = vB.subtract(vA); double lac2 = ac.vectorLengthSquared(); Vector bPerp = ab.subtract(ac.scale(ab.dot(ac)/lac2)); double lbPerp = bPerp.vectorLength(); double lac = Math.sqrt(lac2); return lbPerp/lac; }
@Override protected double getRelativeError (Position a, Position b, Position c) { Vector vA = new Vector(a.getLongitude(), a.getLatitude()); Vector vB = new Vector(b.getLongitude(), b.getLatitude()); Vector vC = new Vector(c.getLongitude(), c.getLatitude()); // a, b, and c really should be Positions, but we're treating them as // straight vectors anyway. Vector ac = vC.subtract(vA); Vector ab = vB.subtract(vA); double lac2 = ac.vectorLengthSquared(); Vector bPerp = ab.subtract(ac.scale(ab.dot(ac)/lac2)); double lbPerp = bPerp.vectorLength(); double lac = Math.sqrt(lac2); return lbPerp/lac; }
@Override protected double getRelativeError (Position a, Position b, Position c) { Vector vA = new Vector(a.getLongitude(), a.getLatitude()); Vector vB = new Vector(b.getLongitude(), b.getLatitude()); Vector vC = new Vector(c.getLongitude(), c.getLatitude()); // a, b, and c really should be Positions, but we're treating them as // straight vectors anyway. Vector ac = vC.subtract(vA); Vector ab = vB.subtract(vA); double lac2 = ac.vectorLengthSquared(); Vector bPerp = ab.subtract(ac.scale(ab.dot(ac)/lac2)); double lbPerp = bPerp.vectorLength(); double lac = Math.sqrt(lac2); return lbPerp/lac; }