Magnetics: Coordinate Systems
Convert points between Cartesian, cylindrical, and spherical coordinates. Check angle conventions and work in radians.
Angles and quadrants
Cylindrical coordinates use r, azimuth, and z. Spherical coordinates are returned as [radius, polar angle measured from +z, azimuth], with both angles in radians. Use radians and check the quadrant with a point whose x and y components are both nonzero. An angle at a pole or the origin may follow a convention.
Operation reference
Jump to an operation
No matching operations.
coordinates.cartesian_to_cylindrical
A contains [x,y,z]. The result is the radius in the xy plane, the azimuth in radians, and z.
- Access
- Registered in the Python Job
- Arguments
- Typed operands a, b, and c, with an optional typed options struct.
- Shape
- N × 3 | optional second operand of shape N × 3
(N_by_3;optional_N_by_3) - Units
- Input coordinate units, radians
- Result
- Numerical and diagnostic fields
- Purpose
- Cartesian to cylindrical coordinate conversion
gxtxt_api_call("MAGNETICS_API_v1", "coordinates.cartesian_to_cylindrical", args)Recorded result · coordinates.cartesian_to_cylindrical
Download the example script (ZIP).
Example operands preview
[
{
"kind": "array",
"shape": [
2,
3
],
"real": [
1.0,
2.0,
1.0,
0.0,
2.0,
1.0
]
},
{
"kind": "empty"
},
{
"kind": "empty"
}
]Result preview
{
"value_real": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
1.4142135623730951,
2.0,
0.7853981633974483,
0.0,
2.0,
1.0
]
},
"value_imaginary": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
}
}coordinates.cylindrical_to_cartesian
A contains the radius in the xy plane, the azimuth in radians, and z. The operation computes x=r cos(azimuth) and y=r sin(azimuth).
- Access
- Registered in the Python Job
- Arguments
- Typed operands a, b, and c, with an optional typed options struct.
- Shape
- N × 3 | optional second operand of shape N × 3
(N_by_3;optional_N_by_3) - Units
- Input coordinate units, radians
- Result
- Numerical and diagnostic fields
- Purpose
- Cylindrical to Cartesian coordinate conversion
gxtxt_api_call("MAGNETICS_API_v1", "coordinates.cylindrical_to_cartesian", args)Recorded result · coordinates.cylindrical_to_cartesian
Download the example script (ZIP).
Example operands preview
[
{
"kind": "array",
"shape": [
1,
3
],
"real": [
1.4142135623730951,
0.7853981633974483,
2.0
]
},
{
"kind": "empty"
},
{
"kind": "empty"
}
]Result preview
{
"value_real": {
"dtype": "float64",
"shape": [
3,
1
],
"values": [
1.0000000000000002,
1.0,
2.0
]
},
"value_imaginary": {
"dtype": "float64",
"shape": [
3,
1
],
"values": [
0.0,
0.0,
0.0
]
}
}coordinates.cartesian_to_spherical
A contains [x,y,z]. The result is [radius, polar angle from +z, azimuth], with both angles in radians.
- Access
- Registered in the Python Job
- Arguments
- Typed operands a, b, and c, with an optional typed options struct.
- Shape
- N × 3 | optional second operand of shape N × 3
(N_by_3;optional_N_by_3) - Units
- Input coordinate units, radians
- Result
- Numerical and diagnostic fields
- Purpose
- Cartesian to spherical coordinate conversion
gxtxt_api_call("MAGNETICS_API_v1", "coordinates.cartesian_to_spherical", args)Recorded result · coordinates.cartesian_to_spherical:components
Download the example script (ZIP).
Example operands preview
[
{
"kind": "array",
"shape": [
2,
3
],
"real": [
1.0,
2.0,
1.0,
0.0,
2.0,
1.0
]
},
{
"kind": "array",
"shape": [
2,
3
],
"real": [
1.0,
0.0,
2.0,
2.0,
0.0,
1.0
],
"imaginary": [
1.0,
0.0,
0.0,
0.0,
0.0,
-1.0
]
},
{
"kind": "empty"
}
]Result preview
{
"value_real": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
2.449489742783178,
2.23606797749979,
0.6154797086703874,
1.1071487177940904,
0.7853981633974483,
0.0
]
},
"value_imaginary": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
},
"components_real": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
1.2247448713915892,
0.44721359549995804,
1.7320508075688772,
-0.8944271909999159,
0.7071067811865477,
2.0
]
},
"components_imaginary": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
0.4082482904638631,
-0.44721359549995804,
0.5773502691896258,
0.8944271909999159,
-0.7071067811865475,
0.0
]
}
}coordinates.spherical_to_cartesian
A contains the radius and angles in radians. Check the round trip with a point away from the coordinate axes.
- Access
- Registered in the Python Job
- Arguments
- Typed operands a, b, and c, with an optional typed options struct.
- Shape
- N × 3 | optional second operand of shape N × 3
(N_by_3;optional_N_by_3) - Units
- Input coordinate units, radians
- Result
- Numerical and diagnostic fields
- Purpose
- Spherical to Cartesian coordinate conversion
gxtxt_api_call("MAGNETICS_API_v1", "coordinates.spherical_to_cartesian", args)Recorded result · coordinates.spherical_to_cartesian:round-trip
Download the example script (ZIP).
Example operands preview
[
{
"kind": "array",
"shape": [
2,
3
],
"real": [
2.449489742783178,
2.23606797749979,
0.6154797086703874,
1.1071487177940904,
0.7853981633974483,
0.0
]
},
{
"kind": "array",
"shape": [
2,
3
],
"real": [
1.2247448713915892,
0.44721359549995804,
1.7320508075688772,
-0.8944271909999159,
0.7071067811865477,
2.0
],
"imaginary": [
0.4082482904638631,
-0.44721359549995804,
0.5773502691896258,
0.8944271909999159,
-0.7071067811865475,
0.0
]
},
{
"kind": "empty"
}
]Result preview
{
"value_real": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
1.0,
2.0,
0.9999999999999999,
0.0,
1.9999999999999998,
1.0000000000000002
]
},
"value_imaginary": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
},
"components_real": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
0.9999999999999999,
0.0,
2.0,
2.0,
0.0,
1.0
]
},
"components_imaginary": {
"dtype": "float64",
"shape": [
2,
3
],
"values": [
1.0,
0.0,
0.0,
0.0,
-5.551115123125783e-17,
-1.0
]
}
}