coords.Coords.project_on_sphere#
- Coords.project_on_sphere(radius=1.0, center=(0.0, 0.0, 0.0))#
Project a
Coordson a sphere.Creates a central projection of a Coords on a sphere.
Parameters#
- radius: float, optional
The radius of the sphere, default 1.
- center: float array_like (3,), optional
The center of the sphere. The default is the origin of the global axes.
Returns#
- Coords
A Coords with the input points projected from the center of the sphere onto its surface.
Notes#
Projection is undefined for points coinciding with the center of the sphere (division by zero). Such points will result in NaN values.
This is a central projection from the center of the sphere. For a parallel projection on a spherical surface, see the last example below.
Examples#
>>> X = Coords([[x,x,1.] for x in range(1,4)]) >>> X Coords([[1., 1., 1.], [2., 2., 1.], [3., 3., 1.]]) >>> X.project_on_sphere() Coords([[0.5774, 0.5774, 0.5774], [0.6667, 0.6667, 0.3333], [0.6882, 0.6882, 0.2294]])
Parallel projection (along the Z-axis) on a sphere with radius 1.5, and center at the origin:
>>> C = Coords([[0.0, 0.0],[1.0, 0.0],[1.0, 1.0],[0.0, 1.0]]) >>> dist = np.sqrt(C.x**2 + C.y**2) >>> C.z = np.sqrt(1.5**2 - dist**2) >>> print(C) [[0. 0. 1.5 ] [1. 0. 1.118] [1. 1. 0.5 ] [0. 1. 1.118]]