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/include/surfaceSample.h | |
download | csci427-master.tar.xz csci427-master.zip |
Diffstat (limited to 'hw6/include/surfaceSample.h')
-rw-r--r-- | hw6/include/surfaceSample.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/hw6/include/surfaceSample.h b/hw6/include/surfaceSample.h new file mode 100644 index 0000000..106c524 --- /dev/null +++ b/hw6/include/surfaceSample.h @@ -0,0 +1,72 @@ +/******************************************************************/ +/* 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. */ +/******************************************************************/ +#ifndef _SURFACESAMPLE_H_ +#define _SURFACESAMPLE_H_ + +#include "transformation3d.h" +#include <ostream> + +class surfaceSample { + public: + surfaceSample(void); + surfaceSample(const vec3d& position, const vec3d& normal, const float pdf); + surfaceSample(const surfaceSample& ss); + + /////////////// + // Operators // + /////////////// + surfaceSample& operator=(const surfaceSample& ss); + + surfaceSample operator*(float pdf) const; + surfaceSample& operator*=(float pdf); + + //////////////// + // Inspectors // + //////////////// + const vec3d& position(void) const; + const vec3d& normal(void) const; + float pdf(void) const; + + ///////////// + // Methods // + ///////////// + surfaceSample& transform(const transformation3d& t); + surfaceSample& inverseTransform(const transformation3d& t); + + ///////////// + // Friends // + ///////////// + friend void swap(surfaceSample& a, surfaceSample& b) { a._swap(b); } + + friend surfaceSample transform(const surfaceSample& s, const transformation3d& t) { surfaceSample result(s); return result.transform(t); } + friend surfaceSample inverseTransform(const surfaceSample& s, const transformation3d& t) { surfaceSample result(s); return result.inverseTransform(t); } + + friend std::ostream& operator<<(std::ostream& s, const surfaceSample& ss) + { + s << "SurfaceSample: " << ss._position << "with normal: " << ss._normal << ", and PDF: " << ss._pdf; + return s; + } + + + private: + ///////////////////// + // Private Methods // + ///////////////////// + void _swap(surfaceSample& s); + void _assign(const surfaceSample& s); + + ////////////////// + // Data Members // + ////////////////// + vec3d _position; + vec3d _normal; + float _pdf; +}; + +#endif /* _SURFACESAMPLE_H_ */ |