Skip to content
Snippets Groups Projects
Commit 81ce0fe6 authored by Jan Caron's avatar Jan Caron
Browse files

Changed default behaviouf of create_vector_homog

3D now always has 3 components, 2D only if theta is specified!
parent 7091c5dd
No related branches found
No related tags found
No related merge requests found
......@@ -37,11 +37,13 @@ def create_vector_homog(dim, phi=0, theta=None, scale=1.0):
assert len(dim) in (2, 3), 'Disc can only be build in 2 or 3 dimensions!'
assert isinstance(phi, Number), 'phi has to be an angle in radians!'
assert isinstance(theta, Number) or theta is None, 'theta has to be an angle in radians or None!'
if theta is None:
if len(dim) == 2 and theta is None: # 2D and 3rd component not explicitely wanted:
y_comp = np.ones(dim) * np.sin(phi)
x_comp = np.ones(dim) * np.cos(phi)
data = np.stack([x_comp, y_comp], axis=-1)
else:
else: # 3D, always have a third component:
if theta is None:
theta = np.pi/2 # xy-plane if not specified otherwise!
z_comp = np.ones(dim) * np.cos(theta)
y_comp = np.ones(dim) * np.sin(theta) * np.sin(phi)
x_comp = np.ones(dim) * np.sin(theta) * np.cos(phi)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment