-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathonb.h
46 lines (31 loc) · 1.23 KB
/
onb.h
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
#ifndef ONB_H_
#define ONB_H_
#include <glm/glm.hpp>
class ONB
{
public:
// The default constructor creates a "standard" ONB.
ONB( void );
// Set up an ONB from an normalized input vector 'v' that will be assumed to be aligned to
// the 'v' (up) vector of the ONB to be created.
void setFromV( const glm::vec3 &v );
// Set up an ONB from the normalized input vectors 'u' and 'w', that will be assumed to be aligned to
// the vectors 'u' (right) and 'w' vectors of the ONB to be created.
void setFromUW( const glm::vec3 &u,
const glm::vec3 &w );
glm::mat3x3 getBasisMatrix( void ) const
{
return m_;
}
// The default ONB is the standard orthonormal basis.
glm::vec3 u_ = { 1.0f, 0.0f, 0.0f };
glm::vec3 v_ = { 0.0f, 1.0f, 0.0f };
glm::vec3 w_ = { 0.0f, 0.0f, 1.0f };
private:
// Builds 'm_' from 'u_', 'v_' and 'w_'.
void setBasisMatrix( void );
// The 'm_' matrix transforms a vector from the ONB to the "external" space (i.e. the space into which the ONB is defined).
// Also, 'm_' helps to keep the code shorter by avoiding the explicit use of dot products in the case of a change of basis.
glm::mat3x3 m_;
};
#endif /* ONB_H_ */