Open israelmcmc opened 1 month ago
Example:
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, dpi = 150)
# From spherical
theta = np.linspace(0,.5*np.pi, 6)
phi = np.linspace(-np.pi/2, np.pi/2, 13)
theta,phi = np.meshgrid(theta,phi)
x = np.sin(theta)*np.cos(phi)
y = np.sin(theta)*np.sin(phi)
z = np.cos(theta)
# Uncomment the option you want
# title = "Orthographic Z"
# px_x = -x*z
# px_y = -y*z
# px_z = x**2 + y**2
# title = "Orthographic X"
# px_x = y**2 + z**2
# px_y = -x*y
# px_z = -x*z
title = "Stereographic"
px_x = 1 - (x**2-y**2)/(z+1)**2
px_y = -2*x*y/(z+1)**2
px_z = -2*x/(z+1)
# Normalize
norm = np.sqrt(px_x**2 +px_y**2 +px_z**2)
px_x /= norm
px_y /= norm
px_z /= norm
# Get the other polarization reference vector.
pz = [x,y,z] # Same as source direction
py_x, py_y, py_z = np.cross(pz,[px_x,px_y,px_z], axis = 0)
# Plot
ax.quiver(x,y,z, px_x,px_y,px_z, length = .2, linewidth = 1.5, color = 'red')
ax.quiver(x,y,z, py_x,py_y,py_z, length = .2, linewidth = 1.5, color = 'blue')
ax.set_xlim(-1,1)
ax.set_ylim(-1,1)
ax.set_zlim(-1,1)
ax.view_init(20,-20)
#ax.view_init(90,20)
ax.set_title(title)
Has only a single pole (undefined point) at the bottom of the detector. Solves the issue of having a singularity within the field of view.