Rev | Line | |
---|
[2197] | 1 | #include "dxstdafx.h"
|
---|
| 2 | #include "Radion.hpp"
|
---|
| 3 | #include <iostream>
|
---|
| 4 |
|
---|
| 5 | Radion::Radion(void)
|
---|
| 6 | {
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | Radion::~Radion(void)
|
---|
| 10 | {
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | double Radion::getFormFactorTo(const Radion& o) const
|
---|
| 14 | {
|
---|
| 15 | Vector diff = position - o.position;
|
---|
| 16 | double dist2 = diff.norm2();
|
---|
| 17 | double cosa = o.normal * diff; // / dist
|
---|
| 18 | double cosb = - (normal * diff); // / dist
|
---|
| 19 | if(cosa < 0 || cosb < 0)
|
---|
| 20 | return 0;
|
---|
| 21 | return cosa * cosb / dist2 / dist2;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | /*std::ostream& operator<<(std::ostream& s, const Radion& r)
|
---|
| 25 | {
|
---|
| 26 | s.write((char*)&r, sizeof(Radion));
|
---|
| 27 | return s;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | std::istream& operator>>(std::istream& s, Radion& r)
|
---|
| 31 | {
|
---|
| 32 | s.read((char*)&r, sizeof(Radion));
|
---|
| 33 | return s;
|
---|
| 34 | }*/
|
---|
| 35 |
|
---|
| 36 | std::ostream& operator<<(std::ostream& s, const Radion& r)
|
---|
| 37 | {
|
---|
| 38 | s << "pos " << r.position.x << ' ' <<
|
---|
| 39 | r.position.y << ' ' <<
|
---|
| 40 | r.position.z << '\n';
|
---|
| 41 |
|
---|
| 42 | s << "normal " << r.normal.x << ' ' <<
|
---|
| 43 | r.normal.y << ' ' <<
|
---|
| 44 | r.normal.z << '\n';
|
---|
| 45 |
|
---|
| 46 | s << "prob " << r.radiance.sum() << '\n';
|
---|
| 47 |
|
---|
| 48 | return s;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | std::istream& operator>>(std::istream& s, Radion& r)
|
---|
| 52 | {
|
---|
| 53 | char k[128];
|
---|
| 54 |
|
---|
| 55 | s >> k >> r.position.x >>
|
---|
| 56 | r.position.y >>
|
---|
| 57 | r.position.z;
|
---|
| 58 | s >> k >> r.normal.x >>
|
---|
| 59 | r.normal.y >>
|
---|
| 60 | r.normal.z;
|
---|
| 61 |
|
---|
| 62 | s >> k >> r.radiance.x;
|
---|
| 63 |
|
---|
| 64 | r.radiance.y = r.radiance.z = 0.0;
|
---|
| 65 |
|
---|
| 66 | return s;
|
---|
| 67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.