Add ColourXyz::from_photon()

This commit is contained in:
Matthew Gordon 2020-09-04 22:01:40 -04:00
parent 425f093756
commit e0d3354a77
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,6 @@
use crate::math::{Mat3, Vec3}; use crate::math::{Mat3, Vec3};
use super::ColourRgbF; use super::{ColourRgbF, Photon};
/// A CIE XYZ Colour Value /// A CIE XYZ Colour Value
#[derive(Clone, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]
@ -28,6 +28,12 @@ impl ColourXyz {
ColourXyz { values } ColourXyz { values }
} }
pub fn from_photon(photon: &Photon) -> ColourXyz {
let mut result = Self::for_wavelength(photon.wavelength);
result.values *= photon.intensity;
result
}
pub fn x(&self) -> f64 { pub fn x(&self) -> f64 {
self.values.x() self.values.x()
} }