summaryrefslogtreecommitdiff
path: root/hw6/include/surfaceSample.h
blob: 106c524839f39e1f74e75eb64bdb9780003a1aa3 (plain) (blame)
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
/******************************************************************/
/* 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_ */