Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
Transform.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/math_fwd.h"
5
6#include <memory>
7
8namespace ph
9{
10 class Time;
11 class Ray;
12 class HitInfo;
13}
14
15namespace ph::math
16{
17
18// TODO: templatize
19// TODO: use line segment, not ray
21{
22public:
23 virtual ~Transform() = default;
24
25 // DEPRECATED
26 virtual std::unique_ptr<Transform> genInversed() const;
27
28 // Treating a Vector3R as either
29 //
30 // 1) vectors (V)
31 // 2) orientations (O) (such as normals and tangents)
32 // 3) points (P)
33 //
34 // and calculate the transformed result.
35
36 void transformV(const Vector3R& vector,
37 Vector3R* out_vector) const;
38 void transformO(const Vector3R& orientation,
39 Vector3R* out_orientation) const;
40 void transformP(const Vector3R& point,
41 Vector3R* out_point) const;
42
43 void transformV(const Vector3R& vector, const Time& time,
44 Vector3R* out_vector) const;
45 void transformO(const Vector3R& orientation, const Time& time,
46 Vector3R* out_orientation) const;
47 void transformP(const Vector3R& point, const Time& time,
48 Vector3R* out_point) const;
49
50 // Notice that transforming a ray neither will change its parametric
51 // distance (t) nor renormalizing its direction vector even if the transform
52 // contains scale factor; because if users respect the ray segment's
53 // definition:
54 //
55 // Ray Segment = [rayOrigin + rayMinT * rayDirection,
56 // rayOrigin + rayMaxT * rayDirection]
57 //
58 // this operation will always yield a correctly transformed result while
59 // saving an expensive sqrt() call.
60 //
61 void transform(const Ray& ray,
62 Ray* out_ray) const;
63
64 void transform(const HitInfo& info,
65 HitInfo* out_info) const;
66 void transform(const AABB3D& aabb,
67 AABB3D* out_aabb) const;
68
69 void transform(const HitInfo& info, const Time& time,
70 HitInfo* out_info) const;
71 void transform(const AABB3D& aabb, const Time& time,
72 AABB3D* out_aabb) const;
73
74private:
75
76 // Treating a Vector3R as either a vector, orientation, or point and
77 // calculate the transformed result.
78
79 virtual void transformVector(const Vector3R& vector, const Time& time,
80 Vector3R* out_vector) const = 0;
81
82 virtual void transformOrientation(const Vector3R& orientation, const Time& time,
83 Vector3R* out_orientation) const = 0;
84
85 virtual void transformPoint(const Vector3R& point, const Time& time,
86 Vector3R* out_point) const = 0;
87
88 // Transform the specified line segment. A line segment's definition is
89 // as follows:
90 //
91 // Line Segment = [lineStartPos + lineMinT * lineDir,
92 // lineStartPos + lineMaxT * lineDir]
93 //
94 // Also note that lineDir is not necessary to be normalized.
95 //
96 virtual void transformLineSegment(const Vector3R& lineStartPos, const Vector3R& lineDir,
97 real lineMinT, real lineMaxT, const Time& time,
98 Vector3R* out_lineStartPos, Vector3R* out_lineDir,
99 real* out_lineMinT, real* out_lineMaxT) const = 0;
100};
101
102}// end namespace ph::math
General information for a ray-primitive intersection.
Definition HitInfo.h:18
Represents a ray in space.
Definition Ray.h:21
Definition Time.h:9
Definition Transform.h:21
void transformO(const Vector3R &orientation, Vector3R *out_orientation) const
Definition Transform.cpp:40
void transform(const Ray &ray, Ray *out_ray) const
Definition Transform.cpp:50
virtual ~Transform()=default
void transformV(const Vector3R &vector, Vector3R *out_vector) const
Definition Transform.cpp:35
virtual std::unique_ptr< Transform > genInversed() const
Definition Transform.cpp:12
void transformP(const Vector3R &point, Vector3R *out_point) const
Definition Transform.cpp:45
Math functions and utilities.
Definition TransformInfo.h:10
The root for all renderer implementations.
Definition EEngineProject.h:6