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 /hw2/include/transformation3d.h | |
download | csci427-master.tar.xz csci427-master.zip |
Diffstat (limited to 'hw2/include/transformation3d.h')
-rw-r--r-- | hw2/include/transformation3d.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/hw2/include/transformation3d.h b/hw2/include/transformation3d.h new file mode 100644 index 0000000..7b61ecc --- /dev/null +++ b/hw2/include/transformation3d.h @@ -0,0 +1,77 @@ +/******************************************************************/ +/* 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 _TRANSFORMATION3D_H_ +#define _TRANSFORMATION3D_H_ + +#include "vec3d.h" +#include "mat3d.h" + +class transformation3d { + public: + ////////////////// + // Constructors // + ////////////////// + transformation3d(void); + transformation3d(const vec3d& translation, const mat3d& transformation, const mat3d& inverseTransform); + transformation3d(const transformation3d& t); + + ////////////// + // Operator // + ////////////// + transformation3d& operator=(const transformation3d& t); + + transformation3d operator*(const transformation3d& t) const; + transformation3d& operator*=(const transformation3d& t); + + ////////////// + // Mutators // + ////////////// + transformation3d& invert(void); + + ///////////// + // Methods // + ///////////// + vec3d transformPoint(const vec3d& p) const; + vec3d transformDirection(const vec3d& d) const; + vec3d transformNormal(const vec3d& n) const; + + vec3d inverseTransformPoint(const vec3d& p) const; + vec3d inverseTransformDirection(const vec3d& d) const; + vec3d inverseTransformNormal(const vec3d& n) const; + + ///////////// + // Friends // + ///////////// + friend void swap(transformation3d& a, transformation3d& b) { a._swap(b); } + + friend transformation3d inverse(const transformation3d& t) { transformation3d i(t); return i.invert(); } + + friend std::ostream& operator<<(std::ostream& s, const transformation3d& t) + { + t._print(s); + return s; + } + + protected: + /////////////////////// + // Protected Methods // + /////////////////////// + void _swap(transformation3d& t); + void _assign(const transformation3d& t); + virtual void _print(std::ostream& s) const; + + //////////////////////////// + // Protected Data Members // + //////////////////////////// + vec3d _translation; + mat3d _transformation; + mat3d _inverseTransformation; +}; + +#endif /* _TRANSFORMATION3D_H_ */ |