You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a function for transforming vectors from one frame to another.
From EMUS:
defget_vec_pxform():
""" Return a vectorized form of spice.pxform function. "Return the matrix that transforms position vectors from one specified frame to another at a specified epoch." https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pxform_c.html """returnnp.vectorize(spice.pxform,
excluded=['fromstr', 'tostr'],
signature='(),(),()->(3,3)',
otypes=[np.float64])
@ensure_spicedefframe_transform(from_frame: SpiceFrame, to_frame: SpiceFrame, et: floatornp.ndarray, position: np.ndarray,
normalize: bool=False) ->np.ndarray:
""" Transform a position <x, y, z> vector between reference frames, optionally normalizing the result. :param from_frame: SpiceFrame, required, Reference frame of position :param to_frame: SpiceFrame, required, Reference frame of output :param et: np.float64 or np.ndarray with dtype np.float64, required, Ephemeris time(s) corresponding to position(s) :param position: np.ndarray, required, <x, y, z> vector or array of vectors in reference frame `from_frame` :param normalize: bool, optional, Optionally normalize the output vector :return: np.ndarray, 3d position vector(s) in reference frame `to_frame` """ifposition.ndim==1:
assertlen(position) ==3assertisinstance(et, float)
elifposition.ndim==2:
assertlen(position) ==len(et)
assertlen(position[0]) ==3vec_pxform=get_vec_pxform()
rotate=vec_pxform(from_frame.value.strid, to_frame.value.strid, et)
ifhasattr(rotate[0][0], '__len__'):
result=np.array([np.matmul(rotate, pos).astype(np.float64) forrotate, posinzip(rotate, position)])
ifnormalize:
result=normalize_vectors(result)
else:
result=np.matmul(rotate, position).astype(np.float64)
ifnormalize:
result=result/np.linalg.norm(result)
returnresult
The text was updated successfully, but these errors were encountered:
Algorithm Description:
Implement a function for transforming vectors from one frame to another.
From EMUS:
The text was updated successfully, but these errors were encountered: