diff options
author | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-03-03 02:49:39 +0700 |
---|---|---|
committer | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-03-03 02:49:39 +0700 |
commit | 8eec1dd60e966f068cd62fba87ca5dbc1aeb1978 (patch) | |
tree | 31f57a20fb600dd8fb3c328d65560d658ff38582 /src/common.rs | |
parent | 988a418f8907fb5e3abb77222929d6ab7b60c1b6 (diff) |
upd camera field of view
Diffstat (limited to 'src/common.rs')
-rw-r--r-- | src/common.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common.rs b/src/common.rs index 120d8b4..75bf600 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,18 +1,23 @@ -use crate::calculus::calculus::Point3; +use crate::calculus::calculus::{Point3, Vec3}; use crate::interval::Interval; // "Ideal" aspect ratio, allowing fraction -pub const ASPECT_RATIO: f32 = 16.0f32 / 9.0f32; +pub const ASPECT_RATIO: f32 = 16.0 / 9.0; pub const IMG_WIDTH: usize = 400; pub const IMG_HEIGHT: usize = get_image_height(IMG_WIDTH, ASPECT_RATIO); pub const VIEWPORT_HEIGHT: f32 = 2.0; pub const FOCAL_LENGTH: f32 = 1.0; -pub const CAMERA_CENTER: Point3 = Point3 { x: 0f32, y: 0f32, z: 0f32 }; +pub const CAMERA_CENTER: Point3 = Point3 { x: 0.0, y: 0.0, z: 0.0 }; pub const SAMPLES_PER_PIXEL: usize = 100; pub const MAX_DEPTH: usize = 50; +pub const VFOV: f32 = 90.0; +pub const LOOK_FROM: Point3 = Point3 { x: -2.0, y: -2.0, z: 1.0 }; +pub const LOOK_AT: Point3 = Point3 { x: 0.0, y: 0.0, z: -1.0 }; +pub const VUP: Vec3 = Vec3 { x: 0.0, y: 1.0, z: 0.0 }; + pub const fn get_image_height(image_width: usize, aspect_ratio: f32) -> usize { let image_height = (image_width as f32 / aspect_ratio) as usize; if image_width < 1 { 1 } else { image_height } |