Skip to content

Fix spectrum samples assignment and refactor logging trajectories #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/materials/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def emission_function(self, point, direction, spectrum, world, ray, primitive, t
wvl_range = spectrum.min_wavelength - spectrum.max_wavelength
shift = 2 * (spectrum.wavelengths - wvl_centre) / wvl_range
radius = sqrt(point.x**2 + point.y**2)
spectrum.samples += cos((shift + 5) * radius)**4
spectrum.samples[:] = cos((shift + 5) * radius)**4
return spectrum


Expand Down
14 changes: 6 additions & 8 deletions demos/optics/logging_trajectories.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@

# External imports
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

# Raysect imports
from raysect.optical import World, translate, rotate, Point3D, d65_white, Ray, Vector3D
from raysect.optical import World, translate, Point3D, Vector3D
from raysect.optical.material.absorber import AbsorbingSurface
from raysect.optical.library import schott
from raysect.primitive import Sphere, Box
from raysect.primitive import Box
from raysect.optical.loggingray import LoggingRay
from raysect.primitive.lens.spherical import *
from raysect.primitive.lens.spherical import BiConvex


world = World()
Expand All @@ -29,7 +27,7 @@
# for each sample direction trace a logging ray and plot the ray trajectory
plt.ion()
fig = plt.figure()
ax = fig.gca(projection='3d')
ax = fig.add_subplot(111, projection='3d')

for u in np.linspace(-0.006, 0.006, 5):
for v in np.linspace(-0.012, 0.012, 11):
Expand All @@ -39,8 +37,8 @@
log_ray.trace(world)

p = [(start.x, start.y, start.z)]
for point in log_ray.log:
p.append((point.x, point.y, point.z))
for intersection in log_ray.log:
p.append((intersection.hit_point.x, intersection.hit_point.y, intersection.hit_point.z))
p = np.array(p)

ax.plot(p[:, 0], p[:, 1], p[:, 2], 'k-')
Expand Down
Loading