def from_vectors(cls, attractor, r, v, epoch=J2000, plane=Planes.EARTH_EQUATOR): """Return `Orbit` from position and velocity vectors. Parameters ---------- attractor : Body Main attractor. r : ~astropy.units.Quantity Position vector wrt attractor center. v : ~astropy.units.Quantity Velocity vector. epoch : ~astropy.time.Time, optional Epoch, default to J2000. plane : ~poliastro.frames.Planes Fundamental plane of the frame. """ assert np.any(r.value), "Position vector must be non zero" ss = rv.RVState(attractor, r, v) return cls(ss, epoch, plane)
def to_vectors(self): """Converts to position and velocity vector representation. """ r, v = coe2rv( self.attractor.k.to(u.km**3 / u.s**2).value, self.p.to(u.km).value, self.ecc.value, self.inc.to(u.rad).value, self.raan.to(u.rad).value, self.argp.to(u.rad).value, self.nu.to(u.rad).value) return rv.RVState(self.attractor, r * u.km, v * u.km / u.s)
def from_vectors(cls, attractor, r, v, epoch=J2000): """Return `Orbit` from position and velocity vectors. Parameters ---------- attractor : Body Main attractor. r : ~astropy.units.Quantity Position vector wrt attractor center. v : ~astropy.units.Quantity Velocity vector. epoch : ~astropy.time.Time, optional Epoch, default to J2000. """ assert np.any(r.value), "Position vector must be non zero" ss = rv.RVState(attractor, r, v) return cls(ss, epoch)