Subversion Repositories gelsvn

Rev

Rev 2 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 12
Line 1... Line 1...
1
#include "Vec3f.h"
1
#include "Vec3f.h"
2
#include "Quaternion.h"
2
#include "Quaternion.h"
3
 
3
 
4
namespace CGLA {
4
namespace CGLA 
-
 
5
{
5
	void Quaternion::make_rot(float angle, const Vec3f& v)
6
  void Quaternion::make_rot(float angle, const Vec3f& v)
6
	{
7
  {
7
		angle = angle/2;
8
    angle = angle/2;
8
		qv = CGLA::normalize(v);
9
    qv = CGLA::normalize(v);
9
		qv *= sin(angle);
10
    qv *= sin(angle);
Line 51... Line 52...
51
         s*(qv[1]*qv[2]-qw*qv[0]), 
52
		  s*(qv[1]*qv[2]-qw*qv[0]), 
52
									s*(qv[0]*qv[2]-qw*qv[1]), 
53
		  s*(qv[0]*qv[2]-qw*qv[1]), 
53
									s*(qv[1]*qv[2]+qw*qv[0]), 
54
		  s*(qv[1]*qv[2]+qw*qv[0]), 
54
									1 - s*(qv[0]*qv[0]+qv[1]*qv[1])};
55
		  1 - s*(qv[0]*qv[0]+qv[1]*qv[1])};
55
		Mat3x3f mat;
56
    Mat3x3f mat;
56
		mat.set(m);
57
    raw_assign(mat, m);
57
		return mat;
58
    return mat;
58
	}
59
  }
59
 
60
 
60
 
61
 
61
	//This function just need to call the right initialiser
62
  //This function just need to call the right initialiser
Line 78... Line 79...
78
									 float(0),             
79
		   float(0),             
79
									 float(0),                   
80
		   float(0),                   
80
									 float(0),                
81
		   float(0),                
81
									 float(1)};
82
		   float(1)};
82
		Mat4x4f mat;
83
    Mat4x4f mat;
83
		mat.set(m);
84
    raw_assign(mat, m);
84
		return mat;
85
    return mat;
85
	}
86
  }
86
 
87
 
87
 
88
 
88
	Vec3f Quaternion::apply(const Vec3f& vec) const
89
  Vec3f Quaternion::apply(const Vec3f& vec) const