https://github.com/iddm/raytracerchallengeproblem
https://github.com/iddm/raytracerchallengeproblem
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/iddm/raytracerchallengeproblem
- Owner: iddm
- Created: 2022-06-16T08:24:50.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-16T08:25:23.000Z (about 4 years ago)
- Last Synced: 2025-01-20T08:08:56.478Z (over 1 year ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The problem with walls in Ray Tracer Challenge
How I use the `rt.rs`:
```rust
let world = crate::rt::test_world_2();
let mut camera = crate::camera!(100, 50, crate::degree!(60));
*camera.get_transform_matrix_mut() = crate::rt::view_transform(
crate::point!(0, 1.5, -5),
crate::point!(0, 1, 0),
crate::normalised_direction!(0, 1, 0),
);
camera.pixel_width = 500;
camera.pixel_height = 500;
let mut ppm = format!(
"P3 {} {} 255\n",
camera.pixel_width, camera.pixel_height
);
let colors = self.camera.render(&self.world);
colors.into_iter().flatten().for_each(|color| {
ppm.push_str(&format!(
"{} {} {} ",
(255.0 * color.r()) as u8,
(255.0 * color.g()) as u8,
(255.0 * color.b()) as u8
));
});
std::fs::write("/tmp/rt.ppm", ppm).expect("Couldn't write data");
```