CartesianRepresentation¶
-
class
astropy.coordinates.
CartesianRepresentation
(x, y=None, z=None, copy=True)[source] [edit on github]¶ Bases:
astropy.coordinates.BaseRepresentation
Representation of points in 3D cartesian coordinates.
Parameters: x, y, z :
Quantity
The x, y, and z coordinates of the point(s). If
x
,y
, andz
have different shapes, they should be broadcastable.copy : bool, optional
If True arrays will be copied rather than referenced.
Attributes Summary
attr_classes
x
The x component of the point(s). xyz
y
The y component of the point(s). z
The z component of the point(s). Methods Summary
from_cartesian
(other)to_cartesian
()transform
(matrix)Transform the cartesian coordinates using a 3x3 matrix. Attributes Documentation
-
attr_classes
= OrderedDict([(u'x', <class 'astropy.units.quantity.Quantity'>), (u'y', <class 'astropy.units.quantity.Quantity'>), (u'z', <class 'astropy.units.quantity.Quantity'>)])¶
-
x
¶ The x component of the point(s).
-
xyz
¶
-
y
¶ The y component of the point(s).
-
z
¶ The z component of the point(s).
Methods Documentation
-
classmethod
from_cartesian
(other)[source] [edit on github]¶
-
to_cartesian
()[source] [edit on github]¶
-
transform
(matrix)[source] [edit on github]¶ Transform the cartesian coordinates using a 3x3 matrix.
This returns a new representation and does not modify the original one.
Parameters: matrix :
ndarray
A 3x3 transformation matrix, such as a rotation matrix.
Examples
We can start off by creating a cartesian representation object:
>>> from astropy import units as u >>> from astropy.coordinates import CartesianRepresentation >>> rep = CartesianRepresentation([1, 2] * u.pc, ... [2, 3] * u.pc, ... [3, 4] * u.pc)
We now create a rotation matrix around the z axis:
>>> from astropy.coordinates.angles import rotation_matrix >>> rotation = rotation_matrix(30 * u.deg, axis='z')
Finally, we can apply this transformation:
>>> rep_new = rep.transform(rotation) >>> rep_new.xyz <Quantity [[ 1.8660254 , 3.23205081], [ 1.23205081, 1.59807621], [ 3. , 4. ]] pc>
-