diff options
author | 53hornet <53hornet@gmail.com> | 2019-02-02 23:33:15 -0500 |
---|---|---|
committer | 53hornet <53hornet@gmail.com> | 2019-02-02 23:33:15 -0500 |
commit | db072ad4dc181eca5a1458656b130beb43f475bf (patch) | |
tree | a3c03c7f5497cb70503e2486662fa85cfb53415a /hw6/src/brdfSample.cpp | |
download | csci427-db072ad4dc181eca5a1458656b130beb43f475bf.tar.xz csci427-db072ad4dc181eca5a1458656b130beb43f475bf.zip |
Diffstat (limited to 'hw6/src/brdfSample.cpp')
-rw-r--r-- | hw6/src/brdfSample.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/hw6/src/brdfSample.cpp b/hw6/src/brdfSample.cpp new file mode 100644 index 0000000..90acfe4 --- /dev/null +++ b/hw6/src/brdfSample.cpp @@ -0,0 +1,116 @@ +/******************************************************************/ +/* This file is part of the homework assignments for CSCI-427/527 */ +/* at The College of William & Mary and authored by Pieter Peers. */ +/* No part of this file, whether altered or in original form, can */ +/* be distributed or used outside the context of CSCI-427/527 */ +/* without consent of either the College of William & Mary or */ +/* Pieter Peers. */ +/******************************************************************/ +#include <cmath> +#include "brdfSample.h" + +////////////////// +// Constructors // +////////////////// +brdfSample::brdfSample(void) +{ + _out = vec3d(0.0f, 0.0f, 1.0f); + _pdf = 0.0f; + _reflectance = color(0.0f); +} + +brdfSample::brdfSample(const vec3d& out, const float pdf, const color& reflectance) +{ + _out = out; + _pdf = std::max(pdf, 0.0f); + _reflectance = reflectance; +} + + +brdfSample::brdfSample(const brdfSample& bs) +{ + _out = bs._out; + _pdf = bs._pdf; + _reflectance = bs._reflectance; +} + + +/////////////// +// Operators // +/////////////// +brdfSample& brdfSample::operator=(const brdfSample& bs) +{ + _assign(bs); + return *this; +} + + +brdfSample brdfSample::operator*(float pdf) const +{ + return brdfSample(_out, _pdf * pdf, _reflectance); +} + + +brdfSample& brdfSample::operator*=(float pdf) +{ + _pdf *= pdf; + return *this; +} + + +//////////////// +// Inspectors // +//////////////// +const vec3d& brdfSample::exitantDirection(void) const +{ + return _out; +} + + +float brdfSample::pdf(void) const +{ + return _pdf; +} + + +const color& brdfSample::reflectance(void) const +{ + return _reflectance; +} + + +///////////// +// Methods // +///////////// +brdfSample& brdfSample::transform(const transformation3d& t) +{ + _out = t.transformDirection(_out); + return *this; +} + + +brdfSample& brdfSample::inverseTransform(const transformation3d& t) +{ + _out = t.inverseTransformDirection(_out); + return *this; +} + + +///////////////////// +// Private Methods // +///////////////////// +void brdfSample::_swap(brdfSample& bs) +{ + swap(_out, bs._out); + std::swap(_pdf, bs._pdf); + swap(_reflectance, bs._reflectance); +} + + +void brdfSample::_assign(const brdfSample& bs) +{ + _out = bs._out; + _pdf = bs._pdf; + _reflectance = bs._reflectance; +} + |