public Vector cross (Vector v) { if (3 != size() || 3 != v.size()) throw new IllegalArgumentException("Attempt to take the cross product of non-3-vectors"); double xa = coord(0); double ya = coord(1); double za = coord(2); double xb = v.coord(0); double yb = v.coord(1); double zb = v.coord(2); return new Vector(ya*zb-za*yb, za*xb-xa*zb, xa*yb-ya*xb); }
public void draw (Graphics2D g, double zeroX, double zeroY, double pixelsPerUnit, int pointsToDraw) { Point lastP = null; for (int i=0; i<pointsToDraw; ++i) { double t = i * 1.0 / pointsToDraw; Vector v = getPoint(t); Point p = new Point((int) Math.round((v.coord(0)-zeroX)*pixelsPerUnit), (int) Math.round((zeroY-v.coord(1))*pixelsPerUnit)); if (null != lastP) g.drawLine(lastP.x, lastP.y, p.x, p.y); lastP = p; } } }
public void draw (Graphics2D g, double zeroX, double zeroY, double pixelsPerUnit, int pointsToDraw) { Point lastP = null; for (int i=0; i<pointsToDraw; ++i) { double t = i * 1.0 / pointsToDraw; Vector v = getPoint(t); Point p = new Point((int) Math.round((v.coord(0)-zeroX)*pixelsPerUnit), (int) Math.round((zeroY-v.coord(1))*pixelsPerUnit)); if (null != lastP) g.drawLine(lastP.x, lastP.y, p.x, p.y); lastP = p; } } }
static private Vector getCoordinateVector(List<Vector> Vs, int coordinate) { int n = Vs.size(); double[] data = new double[n]; for (int i=0; i<n; ++i) { data[i] = Vs.get(i).coord(coordinate); } return new Vector(data); }
static private Vector getCoordinateVector(List<Vector> Vs, int coordinate) { int n = Vs.size(); double[] data = new double[n]; for (int i=0; i<n; ++i) { data[i] = Vs.get(i).coord(coordinate); } return new Vector(data); }
public double getLongitude () { updatePolar(); return _polar.coord(0); }
/** * Gets the elevation of this position. * * @return The elevation of this position in meters * @throws UnsupportedOperationException * if this position doesn't specify an elevation. */ public double getElevation () { if (!_elevationUsed) throw new UnsupportedOperationException("Attempt to get elevation of elevationless position"); updatePolar(); return _polar.coord(2); }
public double getLatitude () { updatePolar(); return _polar.coord(1); }
public double getLongitude () { updatePolar(); return _polar.coord(0); }
/** * Gets the elevation of this position. * * @return The elevation of this position in meters * @throws UnsupportedOperationException * if this position doesn't specify an elevation. */ public double getElevation () { if (!_elevationUsed) throw new UnsupportedOperationException("Attempt to get elevation of elevationless position"); updatePolar(); return _polar.coord(2); }
public double getLatitude () { updatePolar(); return _polar.coord(1); }
@Override protected Position interpolate (Position start, Position end, double t) { Vector sV = start.getAsCartesian(); Vector eV = end.getAsCartesian(); Vector cartesianResult = sV.scale(1 - t).add(eV.scale(t)); Position p = new Position(cartesianResult.coord(0), cartesianResult.coord(1), cartesianResult.coord(2), !start.hasElevation()); p.setPrecision(start.getPrecision()); return p; }
public static Position interpolate (Position a, Position b, double t) { Vector result = SphereUtilities.interpolate(a.getLongitudeRadians(), HALF_PI-a.getLatitudeRadians(), b.getLongitudeRadians(), HALF_PI-b.getLatitudeRadians(), t); Position p = new Position(Math.toDegrees(result.coord(0)), Math.toDegrees(HALF_PI-result.coord(1))); p.setPrecision(a.getPrecision()); return p; } }
@Override protected Position interpolate (Position start, Position end, double t) { Vector sV = start.getAsCartesian(); Vector eV = end.getAsCartesian(); Vector cartesianResult = sV.scale(1 - t).add(eV.scale(t)); Position p = new Position(cartesianResult.coord(0), cartesianResult.coord(1), cartesianResult.coord(2), !start.hasElevation()); p.setPrecision(start.getPrecision()); return p; }
public static Position interpolate (Position a, Position b, double t) { Vector result = SphereUtilities.interpolate(a.getLongitudeRadians(), HALF_PI-a.getLatitudeRadians(), b.getLongitudeRadians(), HALF_PI-b.getLatitudeRadians(), t); Position p = new Position(Math.toDegrees(result.coord(0)), Math.toDegrees(HALF_PI-result.coord(1))); p.setPrecision(a.getPrecision()); return p; } }