예제 #1
0
 def __init__(self,
              position,
              normal=None,
              shape="spherical_biconvex",
              D=None,
              w=None,
              h=None,
              f=None,
              tangent=None,
              type="normal",
              index=1.5):
     self.position = position
     if normal is not None:
         self.normal = unit_vector(normal)
     else:
         self.normal = normal
     self.shape = shape
     self.D = D
     self.w = w
     self.h = h
     self.f = f
     self.surfaces = []
     self.type = type
     self.index = index
     if shape == "spherical_biconvex":
         self.surfaces.append(Circle(position, normal, D=D))
     elif shape == "spherical":
         self.surfaces.append(Sphere(position, D=D))
     else:
         raise ValueError("Unknown shape")
예제 #2
0
 def __init__(self,
              position,
              shape="circular_flat",
              normal=None,
              D=None,
              w=None,
              h=None,
              thickness=10,
              f=None,
              tangent=None,
              type="normal",
              dmd_normal=None):
     self.position = position
     self.shape = shape
     self.D = D
     self.w = w
     self.h = h
     self.thickness = thickness
     self.f = f
     self.type = type
     self.dmd_normal = unit_vector(dmd_normal)
     self.surfaces = []
     if shape == "circular_flat":
         self.normal = unit_vector(normal)
         self.surfaces.append(Circle(position, normal, D=D))
     elif shape == "rectangular_flat":
         self.normal = unit_vector(normal)
         self.surfaces.append(Rectangle(position, normal, tangent, h=h,
                                        w=w))
     elif shape == "circular_concave_spherical":
         self.normal = unit_vector(normal)
         self.rc = self.f * 2
         self.p_rc = self.position + self.normal * self.rc
         self.surfaces.append(Circle(position, normal, D=D))
         self.surfaces.append(Sphere(center=self.p_rc, R=self.rc))
     elif shape == "circular_convex_spherical":
         self.surfaces.append(Sphere(center=self.position, D=self.D))
     else:
         raise ValueError("Unknown shape")
예제 #3
0
edge_thick = 2.4
f = 100
f_back = 97.3
r1 = 60.02
r2 = 353.30
lens_dia = 25.4
h_ = lens_dia / 2
x1_ = r1 - h_ * np.tan(np.arccos(h_ / r1))
x2_ = r2 - h_ * np.tan(np.arccos(h_ / r2))

zero_pos = np.array([0, 0, 0])
center_pos = np.array([0, y_backprinciple, 0])
ball1_pos = np.array(
    [0, y_backprinciple + r1 - (center_thick - (f - f_back)), 0])
ball2_pos = np.array([0, y_backprinciple - r2 + (f - f_back), 0])
lens1 = Sphere(ball1_pos, D=r1 * 2)
lens2 = Sphere(ball2_pos, D=r2 * 2)

lensCOMPOUNDtree = BinaryTree("intersect")
lensCOMPOUNDtree.insertLeft(lens1)
lensCOMPOUNDtree.insertRight(lens2)
lensCOMPOUND = Compound(lensCOMPOUNDtree,
                        surface_behavior="refract",
                        index=1.5167)

Optic_list = []
Optic_list.append(lensCOMPOUND)

test_index_of_world = get_index_at_point(Optic_list, zero_pos)
test_index_of_optic = get_index_at_point(Optic_list, center_pos)
print(f"test_index_of_world = {test_index_of_world}")
예제 #4
0
from general import set_axes_equal
from general_optics import BinaryTree
plt.close("all")

max_ray_run_distance = 150 # mm



mirror1_pos = np.array([0, 50, 0])
mirror2_pos = np.array([15, 50, 0])
mirror3_pos = np.array([30, 50, 0])

ray1_pos = np.array([0, 0, 0])
ray1_direction = np.array([0, 1, 0])

mirror1 = Sphere(mirror1_pos, D=25)
mirror2 = Sphere(mirror2_pos, D=25)
mirror3 = Sphere(mirror3_pos, D=25)
mirrorCOMPOUNDtree = BinaryTree("union")
mirrorCOMPOUNDtree.insertLeft(mirror1)
mirrorCOMPOUNDtree.insertRight("union")
mirrorCOMPOUNDtree.getRightChild().insertLeft(mirror2)
mirrorCOMPOUNDtree.getRightChild().insertRight(mirror3)
mirrorCOMPOUND = Compound(mirrorCOMPOUNDtree)
Optic_list = []
Optic_list.append(mirrorCOMPOUND)



Ray_list = []
ray_z = np.linspace(0, 0, 1)
import numpy as np
from optics3d import Ray, Compound, add_faerie_fire_rays
import matplotlib.pyplot as plt
import matplotlib.tri as mtri
import copy
from Shapes.shapes import Sphere
from general import set_axes_equal
from general_optics import BinaryTree
plt.close("all")

max_ray_run_distance = 150  # mm

center_pos = np.array([0, 50, 0])
mirror1_pos = np.array([0, 60, 0])
mirror2_pos = np.array([0, 40, 0])
mirror1 = Sphere(mirror1_pos, D=30)
mirror2 = Sphere(mirror2_pos, D=30)

mirrorCOMPOUNDtree = BinaryTree("difference")
mirrorCOMPOUNDtree.insertLeft(mirror1)
mirrorCOMPOUNDtree.insertRight(mirror2)
mirrorCOMPOUND = Compound(mirrorCOMPOUNDtree)

Optic_list = []
Optic_list.append(mirrorCOMPOUND)

Ray_list = []
FF_N = 1000
FF_radius = max_ray_run_distance - 50
FF_center = center_pos
Ray_list = add_faerie_fire_rays(Ray_list, FF_radius, FF_center, FF_N)
예제 #6
0
# -*- coding: utf-8 -*-
"""
Created on 11/19/2019

@author: samuel
"""

from general_optics import BinaryTree, postOrderEval
from Shapes.shapes import Sphere
import numpy as np

cen1 = np.array([1, 1, 1])
cen2 = np.array([-3, -3, -3])
cen3 = np.array([3, -1, 3])
cen4 = np.array([1, 5, -1])

# result should be 15

r = BinaryTree('union')
r.insertLeft('difference')
r.insertRight(Sphere(center=cen1, D=1))
r.getLeftChild().insertLeft('intersect')
r.getLeftChild().insertRight(Sphere(center=cen2, D=1))
r.getLeftChild().getLeftChild().insertLeft(Sphere(center=cen3, D=1))
r.getLeftChild().getLeftChild().insertRight(Sphere(center=cen4, D=1))

a = postOrderEval(r)
print(a)
예제 #7
0
def my_sphere():
    return Sphere(np.array([0, 10, 0]), R=1)
import numpy as np
from optics3d import Ray, Compound, add_faerie_fire_rays
import matplotlib.pyplot as plt
from Shapes.shapes import Sphere
from general import set_axes_equal
from general_optics import BinaryTree
plt.close("all")

max_ray_run_distance = 150 # mm



center_pos = np.array([0, 50, 0])
mirror1_pos = np.array([0, 80, 0])
mirror2_pos = np.array([0, 20, 0])
mirror1 = Sphere(mirror1_pos, D=65)
mirror2 = Sphere(mirror2_pos, D=65)


mirrorCOMPOUNDtree = BinaryTree("intersect")
mirrorCOMPOUNDtree.insertLeft(mirror1)
mirrorCOMPOUNDtree.insertRight(mirror2)
mirrorCOMPOUND = Compound(mirrorCOMPOUNDtree, surface_behavior="reflect", index=1.5)


Optic_list = []
Optic_list.append(mirrorCOMPOUND)

Ray_list = []

FF_radius = max_ray_run_distance - 50