# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import visualProjector as vp
import imp
import matplotlib.pyplot as plt
import numpy as np
imp.reload(vp)

size= 1600
sizeR = [size+1,np.int(size/2)]
proj = vp.Projector(size = size)

proj.addObject(3,0,0)
proj.addObject(-3,0,0)
proj.addObject(0,3,0)
proj.addObject(0,-3,0)
proj.addObject(0,0,3)
proj.addObject(0,0,-3)

# +
#-10 up on image

X = proj.render(True)

# +



# -

proj.image()

fig = plt.figure(figsize = (20,20))
plt.imshow(proj.image())

theta = np.linspace(-np.pi/2,np.pi/2,sizeR[1])
phi = np.linspace(-np.pi,np.pi,sizeR[0])
phi2d = np.array([phi,]*sizeR[1])
theta2d = np.array([theta,]*sizeR[0]).transpose()
sinThetaIm = np.sin(theta2d)
cosThetaCosPhiIm = np.cos(theta2d) * np.cos(phi2d)
cosThetaSinPhiIm = np.cos(theta2d) * np.sin(phi2d)
sinTheta = np.matrix.flatten(np.sin(theta2d))
cosThetaCosPhi = np.matrix.flatten(np.cos(theta2d) * np.cos(phi2d))
cosThetaSinPhi = np.matrix.flatten(np.cos(theta2d) * np.sin(phi2d))

theta2d

fig=plt.figure(figsize = (20,20))
plt.imshow(sinThetaIm)
fig=plt.figure(figsize = (20,20))
plt.imshow(cosThetaSinPhiIm)
fig=plt.figure(figsize = (20,20))
plt.imshow(proj.image()*cosThetaCosPhiIm)
fig=plt.figure(figsize = (20,20))
plt.imshow(proj.image()*cosThetaSinPhiIm)

print(proj.image()[4,:-1])
fig = plt.figure(figsize=(10,50))
plt.plot(cosThetaCosPhiIm[4,:-1],'o')

np.sum(proj.image()[4,:-1]*cosThetaCosPhiIm[4,:-1])
fig = plt.figure(figsize=(10,20))
plt.plot(proj.image()[4,:-1]*cosThetaCosPhiIm[4,:-1],'o')
plt.plot(proj.image()[4,:-1])

np.sum(proj.pixels*np.matrix.flatten(sinTheta))

proj.pixels*np.matrix.flatten(sinTheta[:-1])

plt.imshow(1/np.cos(theta2d)[:
                             
                             
                             
                             
                             
                             
                             ,:-1])

np.sum(np.sin(phi2d))

np.sum(np.cos(phi[:-1]))

plt.plot(np.cos(phi),'o')

np.sum(cosThetaCosPhiIm[:-1,:-1])



plt.plot(proj.image()[int(sizeR[1]/2),:-1]*cosThetaCosPhiIm[int(sizeR[1]/2),:-1],'o')

plt.plot(proj.image()[int(sizeR[1]/2),:-1])

# +

Y=[]
X=[]
for k in range(0,sizeR[1]):
    X.append(np.sum(proj.image()[k,:-1]*cosThetaCosPhiIm[k,:-1]))
print(np.sum(proj.image()[:,:-1]*cosThetaCosPhiIm[:,:-1]))
for k in range(0,sizeR[0]):
    Y.append(np.sum(proj.image()[:,k]*cosThetaCosPhiIm[:,k]))
# -

plt.plot(X)
plt.plot(Y)







StarcoderdataJupyterScriptsDedupFiltered