This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spectrum.h
76 lines (59 loc) · 1.59 KB
/
spectrum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2016 Kai Luo. All rights reserved.
#ifndef ZLI_SPECTRUM_H_
#define ZLI_SPECTRUM_H_
#include <cmath>
#include <iostream>
#include "color.h"
#include "core_math.h"
#include "diagram2d.h"
namespace zLi {
class Spectrum {
public:
static const int NrSpectralSamples;
static const Float DefaultSampleX[];
static const Float DefaultSampleY[];
Spectrum();
explicit Spectrum(Float v);
Spectrum(const Float *, const Float *, size_t);
Spectrum(const Spectrum &) = default;
Spectrum &operator+=(const Spectrum &sp) {
spd_ += sp.spd_;
return *this;
}
Spectrum &operator*=(const Spectrum &sp) {
spd_ *= sp.spd_;
return *this;
}
Spectrum &operator*=(Float f) {
spd_ *= f;
return *this;
}
Spectrum &operator/=(Float f) {
spd_ *= 1 / f;
return *this;
}
friend Spectrum operator+(const Spectrum &a, const Spectrum &b) {
return Spectrum(a.spd_ + b.spd_);
}
friend Spectrum operator*(const Spectrum &a, const Spectrum &b) {
return Spectrum(a.spd_ * b.spd_);
}
friend Spectrum operator*(const Spectrum &a, Float f) {
return Spectrum(a.spd_ * f);
}
friend Spectrum operator*(Float f, const Spectrum &a) {
return Spectrum(a.spd_ * f);
}
friend Spectrum operator/(const Spectrum &a, Float f) {
return Spectrum(a.spd_ * (1 / f));
}
void Display(std::ostream &out) { return spd_.Display(out); }
XYZColor ToXYZ() const;
RGBColor ToRGB() const;
xyYColor ToxyY() const;
private:
explicit Spectrum(const Diagram2D &s) : spd_(s) {}
Diagram2D spd_; // Spectral power distribution
};
} // namespace zLi
#endif