From db072ad4dc181eca5a1458656b130beb43f475bf Mon Sep 17 00:00:00 2001 From: 53hornet <53hornet@gmail.com> Date: Sat, 2 Feb 2019 23:33:15 -0500 Subject: Init. --- hw6/include/surfaceSample.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 hw6/include/surfaceSample.h (limited to 'hw6/include/surfaceSample.h') 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 + +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_ */ -- cgit v1.2.3