private void calculateElements(double t)
			throws JPLEphemerisException {
		ephemeris.calculatePositionAndVelocity(t, JPLEphemeris.NEPTUNE,
				position, velocity);
		
		position.rotate(OBLIQUITY, Vector.X_AXIS);
		velocity.rotate(OBLIQUITY, Vector.X_AXIS);
		
		position.multiplyBy(AU);
		velocity.multiplyBy(AU*K);
		
		double r = position.magnitude();
		double v = velocity.magnitude();
		
		double alpha = v * v - 2.0/r;
		double a = -1.0/alpha;
		
		double d0 = position.scalarProduct(velocity);
		
		double c0 = 1.0 + alpha * r;
		
		double ecc = Math.sqrt(c0 * c0 - alpha * d0 * d0);
		
		V0.linearCombination(velocity, r, position, -d0/r);
		V0.normalise();
		
		double kt0 = c0/ecc;
		double st0 = d0/ecc;
		double xw0 = r * kt0 - d0 * st0;
		
		U0.copy(position);
		U0.normalise();
		
		P.linearCombination(U0, kt0, velocity, -st0);
		P.normalise();
		
		Q.linearCombination(U0, st0, velocity, xw0);
		Q.normalise();
		
		Vector W = P.vectorProduct(Q);
		
		double xi = Math.sqrt(W.getX() * W.getX() + W.getY() * W.getY());
		double yi = W.getZ();
		
		double incl = Math.atan2(xi, yi);
		
		incl *= 180.0/Math.PI;
		
		double node = Math.atan2(W.getX(), -W.getY());
		
		while (node < 0.0)
			node += TWO_PI;
		
		node %= TWO_PI;
		
		double apse = node + Math.atan2(P.getZ(), Q.getZ());
		
		while (apse < 0.0)
			apse += TWO_PI;
		
		apse %= TWO_PI;
		
		double eAnomaly = Math.atan2(st0*Math.sqrt(-alpha), kt0);
		
		double mAnomaly = eAnomaly - ecc * Math.sin(eAnomaly);
		
		double lambda = apse + mAnomaly;
		
		while (lambda < 0.0)
			lambda += TWO_PI;
		
		node *= 180.0/Math.PI;
		apse *= 180.0/Math.PI;
		lambda *= 180.0/Math.PI;
		
		lambda -= MEAN_MOTION * (t - J2000);
		while (lambda < 0.0)
			lambda += 360.0;
		
		lambda %= 360.0;

		System.out.print(dfmt1.format(t));
		System.out.print(' ');
		
		System.out.print(dfmt2.format(a));
		System.out.print(' ');
		System.out.print(dfmt2.format(ecc));
		System.out.print(' ');
		System.out.print(dfmt2.format(incl));
		System.out.print(' ');
		System.out.print(dfmt2.format(node));
		System.out.print(' ');
		System.out.print(dfmt2.format(apse));
		System.out.print(' ');
		System.out.print(dfmt2.format(lambda));

		System.out.println();
	}