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}") print(f"test_index_of_optic = {test_index_of_optic}") max_ray_run_distance = 550
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) ray_x = np.linspace(-20, 55, 76) for x_ix, x_val in enumerate(ray_x): for z_ix, z_val in enumerate(ray_z):
""" import numpy as np from optics3d import Ray, Compound, add_faerie_fire_rays import matplotlib.pyplot as plt from Shapes.shapes import InfiniteCylinder from general import set_axes_equal from general_optics import BinaryTree plt.close("all") y_center = 0 center_pos = np.array([0, 2, 0]) cyl1_pos = np.array([0, 2, 0]) shape1 = InfiniteCylinder(cyl1_pos, R=2, direction=[0, 1, 1]) shapeCOMPOUNDtree = BinaryTree(shape1) shapeCOMPOUND = Compound(shapeCOMPOUNDtree, surface_behavior="reflect", index=1.5167) Optic_list = [] Optic_list.append(shapeCOMPOUND) max_ray_run_distance = 10 x_start = [-6] y_start = [2] z_start = np.linspace(-2.0, 2.0, 21) Ray_list = [] for x_val in x_start:
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) for ray in Ray_list: ray.run(max_distance=max_ray_run_distance, optic_list=Optic_list)
# -*- 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)
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 FF_center = center_pos Ray_list = add_faerie_fire_rays(Ray_list, FF_radius, FF_center)