1 #ifndef CMU462_SPECTRUM_H
2 #define CMU462_SPECTRUM_H
28 Spectrum(
double r = 0,
double g = 0,
double b = 0) : r(r), g(g), b(b) {}
51 return Spectrum(r * rhs.r, g * rhs.g, b * rhs.b);
61 inline Spectrum operator*(
double s)
const {
62 return Spectrum(r * s, g * s, b * s);
65 inline Spectrum &operator*=(
double s) {
72 inline bool operator==(
const Spectrum &rhs)
const {
73 return r == rhs.r && g == rhs.g && b == rhs.b;
76 inline bool operator!=(
const Spectrum &rhs)
const {
77 return !operator==(rhs);
80 inline Color toColor()
const {
return Color(r, g, b, 1); }
82 static Spectrum fromColor(
const Color &c) {
83 return Spectrum(c.a * c.r, c.a * c.g, c.a * c.b);
89 inline Spectrum operator*(
double s,
const Spectrum &c) {
return c * s; }
92 std::ostream &operator<<(std::ostream &os,
const Spectrum &c);
96 #endif // CMU462_SPECTRUM_H
double b
intensity of blue spectrum
Definition: spectrum.h:19
Encodes radiance & irradiance values by the intensity of each visible spectrum.
Definition: spectrum.h:15
Spectrum(double r=0, double g=0, double b=0)
Parameterized Constructor.
Definition: spectrum.h:28
double g
intensity of green spectrum
Definition: spectrum.h:18
double r
intensity of red spectrum
Definition: spectrum.h:17