In [ ]:
from vpython import *

#This iteration projects rays from a sphere projecting to the surface of a larger spheroid.

spikeball = sphere(pos = vector(0, 0, 0), radius = 0.01, color = color.white)
r = curve(pos = [(0,0,0), (0,0,0)])

r.aa = curve(pos = [(0,0,0),(1, 0, 0)], color = color.yellow) #Set of rays along each axis (+/- x, +/- y, +/- z)
r.ab = curve(pos = [(0,0,0),(-1, 0, 0)], color = color.yellow)
r.ac = curve(pos = [(0,0,0),(0, 1, 0)], color = color.yellow)
r.ad = curve(pos = [(0,0,0),(0, -1, 0)], color = color.yellow)
r.ae = curve(pos = [(0,0,0),(0, 0, 1)], color = color.yellow)
r.af = curve(pos = [(0,0,0),(0, 0, -1)], color = color.yellow)

r.ba = curve(pos = [(0,0,0),(100/141.421, 100/141.421, 0)], color = color.yellow) #Set of rays in 2D planes of two coordinate axes
r.bb = curve(pos = [(0,0,0),(-100/141.421, 100/141.421, 0)], color = color.yellow)
r.bc = curve(pos = [(0,0,0),(100/141.421, -100/141.421, 0)], color = color.yellow)
r.bd = curve(pos = [(0,0,0),(-100/141.421, -100/141.421, 0)], color = color.yellow)
r.be = curve(pos = [(0,0,0),(100/141.421, 0, 100/141.421)], color = color.yellow)
r.bf = curve(pos = [(0,0,0),(-100/141.421, 0, 100/141.421)], color = color.yellow)
r.bg = curve(pos = [(0,0,0),(100/141.421, 0, -100/141.421)], color = color.yellow)
r.bh = curve(pos = [(0,0,0),(-100/141.421, 0, -100/141.421)], color = color.yellow)
r.bi = curve(pos = [(0,0,0),(0, 100/141.421, 100/141.421)], color = color.yellow)
r.bj = curve(pos = [(0,0,0),(0, -100/141.421, 100/141.421)], color = color.yellow)
r.bk = curve(pos = [(0,0,0),(0, 100/141.421, -100/141.421)], color = color.yellow)
r.bl = curve(pos = [(0,0,0),(0, -100/141.421, -100/141.421)], color = color.yellow)

r.ca = curve(pos = [(0,0,0), (100/173.205081,100/173.205081,100/173.205081)], color = color.yellow) #Set of rays along no explicit axis
r.cb = curve(pos = [(0,0,0), (-100/173.205081,100/173.205081,100/173.205081)], color = color.yellow)
r.cc = curve(pos = [(0,0,0), (100/173.205081,-100/173.205081,100/173.205081)], color = color.yellow)
r.cd = curve(pos = [(0,0,0), (100/173.205081,100/173.205081,-100/173.205081)], color = color.yellow)
r.ce = curve(pos = [(0,0,0), (-100/173.205081,-100/173.205081,100/173.205081)], color = color.yellow)
r.cf = curve(pos = [(0,0,0), (-100/173.205081,-100/173.205081,-100/173.205081)], color = color.yellow)
r.cg = curve(pos = [(0,0,0), (100/173.205081,-100/173.205081,-100/173.205081)], color = color.yellow)
r.ch = curve(pos = [(0,0,0), (-100/173.205081,100/173.205081,-100/173.205081)], color = color.yellow)

In [ ]:
from vpython import *

spikecube = sphere(pos = vector(0, 0, 0), radius = 0.01, color = color.white)
r = curve(pos = [(0,0,0), (0,0,0)])

r.aa = curve(pos = [(0,0,0),(1, 0, 0)], color = color.yellow) #Set of rays along each axis (+/- x, +/- y, +/- z)
r.ab = curve(pos = [(0,0,0),(-1, 0, 0)], color = color.yellow)
r.ac = curve(pos = [(0,0,0),(0, 1, 0)], color = color.yellow)
r.ad = curve(pos = [(0,0,0),(0, -1, 0)], color = color.yellow)
r.ae = curve(pos = [(0,0,0),(0, 0, 1)], color = color.yellow)
r.af = curve(pos = [(0,0,0),(0, 0, -1)], color = color.yellow)

r.ba = curve(pos = [(0,0,0),(1, 1, 0)], color = color.yellow) #Set of rays in 2D planes of two coordinate axes
r.bb = curve(pos = [(0,0,0),(-1, 1, 0)], color = color.yellow)
r.bc = curve(pos = [(0,0,0),(1, -1, 0)], color = color.yellow)
r.bd = curve(pos = [(0,0,0),(-1, 0, -1)], color = color.yellow)
r.be = curve(pos = [(0,0,0),(1, 0, 1)], color = color.yellow)
r.bf = curve(pos = [(0,0,0),(-1, 0, 1)], color = color.yellow)
r.bg = curve(pos = [(0,0,0),(1, 0, -1)], color = color.yellow)
r.bh = curve(pos = [(0,0,0),(-1, 0, -1)], color = color.yellow)
r.bi = curve(pos = [(0,0,0),(0, 1, 1)], color = color.yellow)
r.bj = curve(pos = [(0,0,0),(0, -1, 1)], color = color.yellow)
r.bk = curve(pos = [(0,0,0),(0, 1, -1)], color = color.yellow)
r.bl = curve(pos = [(0,0,0),(0, -1, -1)], color = color.yellow)

r.ca = curve(pos = [(0,0,0), (1,1,1)], color = color.yellow) #Set of rays along no explicit axis
r.cb = curve(pos = [(0,0,0), (-1,1,1)], color = color.yellow)
r.cc = curve(pos = [(0,0,0), (1,-1,1)], color = color.yellow)
r.cd = curve(pos = [(0,0,0), (1,1,-1)], color = color.yellow)
r.ce = curve(pos = [(0,0,0), (-1,-1,1)], color = color.yellow)
r.cf = curve(pos = [(0,0,0), (-1,-1,-1)], color = color.yellow)
r.cg = curve(pos = [(0,0,0), (1,-1,-1)], color = color.yellow)
r.ch = curve(pos = [(0,0,0), (-1,1,-1)], color = color.yellow)

In [ ]:
#Full Sphere of rays (point source)
from vpython import *
import numpy 


list_of_rays=[]  # Create an empty list named 'list_of_rays'
L=1  #Define a length for the rays

for i in numpy.arange(0,2*pi+0.1,.1):
    for k in numpy.arange(0,2*pi+0.1,.1):
    
        x=L*cos(k)*cos(i) #Prints vector with endpoint along a sphere
        y=L*cos(k)*sin(i) #Equation for a sphere in Spherical Coordinates
        z=L*sin(k)
    
        pointSource = sphere(pos = vector(0, 0, 0), radius = 0.01, color = color.white)
        rays = curve(pos=[vec(0,0,0),vec(x,y,z)], color=color.green)
  #  list_of_rays.append(new_curve)

In [ ]:
#This cell generates a beam of Parallel Rays (Uniform Step Size)
from vpython import *
import numpy 

L=10  #Define a length for the rays


for i in numpy.arange(0,1,.06):
        for k in numpy.arange(0,2*pi+0.1,.1):

            x1 = 0
            x2 = L
            y1 = i*sin(k)
            y2 = y1
            z1 = i*cos(k)
            z2 = z1
        
            beam = curve(pos=[vec(x1,y1,z1),vec(x2,y2,z2)], color=color.red)

In [ ]:
#This cell generates a beam of Parallel Rays (Step Size accounting for Gaussian distribution of beam density)
from vpython import *
import numpy 

L=10  #Define a length for the rays


for i in numpy.arange(0,1.15,.15):
    for j in numpy.arange(0,1+(1/e*e),pow(e,-2*i)): #Taking Gaussian Function for Radial Step 'i'
        for k in numpy.arange(0,2*pi+0.1,.1):

            x1 = 0
            x2 = L
            y1 = j*sin(k)
            y2 = y1
            z1 = j*cos(k)
            z2 = z1
        
            beam = curve(pos=[vec(x1,y1,z1),vec(x2,y2,z2)], color=color.red)

In [ ]:
#This cell generates a beam of Parallel Rays (Uniform Step Size)
from vpython import *
import numpy 

L=10  #Define a length for the rays




for i in numpy.arange(0,1,.06):
        for k in numpy.arange(0,2*pi+0.1,.1):
            
                x1 = 0
                x2 = L
                y1 = i*sin(k)
                y2 = y1
                z1 = i*cos(k)
                z2 = z1
                
              
                for x in numpy.arange(0,5,1):
                    beam = curve(pos=[vec(x1,y1,z1),vec(x2,y2,z2)], color=color.red)
                for x in numpy.arange(5,10,.1):
                    beam = curve(pos=[vec(x1,y1,z1),vec(x2,y2,z2)], color=color.green)

In [ ]:
#This cell generates a beam of Parallel Rays (Uniform Step Size) and changes the color as the beam passes x = 5
from vpython import *
import numpy 

L=10  #Define a length for the rays




for i in numpy.arange(0,1,.06):
        for k in numpy.arange(0,2*pi+0.1,.1):
            
                x1 = 0
                x2 = L
                y1 = i*sin(k)
                y2 = y1
                z1 = i*cos(k)
                z2 = z1
                
                beam = curve(pos=vec(x1,y1,z1), color=color.red)
                beam.append(pos=vec(5,y1,z1), color=color.red)
                beam.append(pos=vec(5,y1,z1), color=color.green)
                beam.append(pos=vec(x2,y2,z2), color=color.green)
                
#This is plotting a new curve that changes color from red to green at a prespecified point (x = 5).
#Can we make this change point variable?  or user input?

In [1]:
#This cell generates a beam of Parallel Rays (Uniform Step Size) and changes the direction as the beam passes x = 5
from vpython import *
import numpy 

L=10  #Define a length for the rays


for i in numpy.arange(0,1,.06):
        for k in numpy.arange(0,2*pi+0.1,.1):
            
                x1 = 0
                x2 = L
                y1 = i*sin(k)
                y2 = y1
                z1 = i*cos(k)
                z2 = z1
                
                beam = curve(pos=vec(x1,y1,z1), color=color.red)
                beam.append(pos=vec(5,y1,z1), color=color.red)
                beam.append(pos=vec(5,y1,z1), color=color.red)
                beam.append(pos=vec(x2,y2,z2), color=color.red)
                
                #Define Vectors
                R = vector(1,0,0) #Vector along x-axis; just rays
                P = vector(-1,-1,-1) #Normal vector for a plane somewhere
                
                beam.append(pos=vec(x_o + dx, y_o + dy, z_o + dz) #Using (numpy.arcsin((1/(1.5))*sin(vector.diff_angle(R,P))))
                
#This is plotting a new curve that changes color from red to green at a prespecified point (x = 5).
#Can we make this change point variable?  or user input?



In [ ]: