rust_pathtracer/
light.rs

1
2use crate::prelude::*;
3
4#[derive(PartialEq, Clone, Debug)]
5/// An analytical light.
6pub struct AnalyticalLight {
7    pub light           : Light,
8}
9
10impl AnalyticalLight {
11
12    /// Creates a spherical light based on its position, radius and emission.
13    pub fn spherical(position: F3, radius: F, emission: F3) -> Self {
14
15        let light = Light {
16            light_type          : LightType::Spherical,
17            position            : position,
18            emission            : emission,
19            u                   : F3::zeros(),
20            v                   : F3::zeros(),
21            radius              : radius,
22            area                : 4.0 * crate::PI * radius * radius
23        };
24
25        Self {
26            light,
27        }
28    }
29}