-
Notifications
You must be signed in to change notification settings - Fork 0
/
vec3.h
52 lines (37 loc) · 1.12 KB
/
vec3.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
46
47
48
49
50
51
52
#ifndef __GWU_SZ_VEC__
#define __GWU_SZ_VEC__
#include <assert.h>
//================================
// vec3
//================================
class vec3 {
public :
float x, y, z;
public :
vec3();
vec3( float x, float y, float z );
vec3 & set( float x, float y, float z );
vec3 & zero( void );
vec3 operator- ( void ) const;
vec3 operator+ ( void ) const;
vec3 operator+ ( const vec3 &v ) const;
vec3 operator- ( const vec3 &v ) const;
vec3 operator* ( float scalar ) const;
vec3 operator/ ( float scalar ) const;
vec3 & operator= ( const vec3 &v );
vec3 & operator+=( const vec3 &v );
vec3 & operator-=( const vec3 &v );
vec3 & operator*=( float scalar );
vec3 & operator/=( float scalar );
float & operator[]( int index );
const float & operator[]( int index ) const;
float dot( const vec3 &v ) const;
vec3 cross(const vec3 &v) const; /// adding cross
float magnitude( void ) const;
vec3 & normalize( void );
float * ptr( void );
const float * ptr( void ) const;
public :
friend vec3 operator*( float scalar, const vec3 &v );
};
#endif // __GWU_SZ_VEC__