Light Around a Black Hole
Light paths bend around a non-rotating black hole. The trails make the paths visible; their colors are just visual guides.
Published
No video preview yet
Source
use "@hyle/maths";
use models { Photon, LightTrail, BlackHole, Emitter };
// Capture radius is 4 physical units. Inset the voxel surface by half a unit
// so rounded trail markers never collide with the visual boundary before capture.
place BlackHole in sphere([0,0,0],7.0) {
set target.shade=maths::clip((position.z+8.0)/16.0,0.0,1.0);
}
// Each beam starts with a ray, a short incident trail, and a repeating source.
// Search only a 5x5 patch around an integer estimate of the transverse launch site.
fn beam(y: Int, z: Int, id: Int, radius: Float) -> Object {
let norm=maths::sqrt((y*y+z*z)*1.0);
let py=radius*y/norm; let pz=radius*z/norm;
let r=maths::sqrt(144.0+radius*radius);
let speed=1.0/maths::sqrt(1.0-4.0*radius*radius/(r*r*r));
// Initialize the same motion diagnostic that the integrator later records.
let advance=2.0*maths::minimum(0.5,0.04*r)*speed;
return object {
place Photon in box([-24,y-2,z-2],[-23,y+3,z+3]) when maths::abs(position.y-2.0*py)<0.5 && maths::abs(position.z-2.0*pz)<0.5 {
set target.ray.p=RayVector { x:-12.0,y:py,z:pz };
set target.ray.v=RayVector { x:speed,y:0.0,z:0.0 };
set target.ray.anchor=RayVector { x:-24.0,y:position.y*1.0,z:position.z*1.0 };
set target.ray.angular=radius*radius*speed*speed;
set target.ray.id=id*1.0;
set target.ray.delay=id*0.4;
set target.ray.speed=advance;
}
place LightTrail in box([-32,y-2,z-2],[-24,y+3,z+3]) when maths::abs(position.y-2.0*py)<0.5 && maths::abs(position.z-2.0*pz)<0.5 {
set target.speed=advance;
}
// Place after the incident trail; this source remains fixed at X=-25.
place Emitter in box([-25,y-2,z-2],[-24,y+3,z+3]) when maths::abs(position.y-2.0*py)<0.5 && maths::abs(position.z-2.0*pz)<0.5 {
set target.launch.p=RayVector { x:-12.0,y:py,z:pz };
set target.launch.v=RayVector { x:speed,y:0.0,z:0.0 };
set target.launch.anchor=RayVector { x:-24.0,y:position.y*1.0,z:position.z*1.0 };
set target.launch.angular=radius*radius*speed*speed;
set target.launch.id=id*1.0+48.0;
set target.countdown=10.0+id*0.4;
set target.launch.speed=advance;
}
};
}
// Forty-eight rays surround the hole in 3D. The second ring lies just outside the
// capture threshold. Slight radial and launch-time staggering separates crossings.
let dy=[10,9,5,0,-5,-9,-10,-9,-5,0,5,9];
let dz=[0,5,9,10,9,5,0,-5,-9,-10,-9,-5];
let diameter=[12,20,23,27];
let impact=[6.0,9.88,11.3,13.2];
for ring in 0..4 {
for spoke in 0..12 {
place beam(dy[spoke]*diameter[ring]/10,dz[spoke]*diameter[ring]/10,
ring*12+spoke,impact[ring]+spoke*0.025) at [0,0,0];
}
}