68 lines
1.7 KiB
Plaintext
68 lines
1.7 KiB
Plaintext
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
|
// See the file tools.license for terms.
|
|
|
|
#ifndef tools_rotd
|
|
#define tools_rotd
|
|
|
|
// rotation done with quaternion.
|
|
|
|
#include "qrot"
|
|
#include "vec3d"
|
|
#include "vec4d"
|
|
#include "mat3d"
|
|
#include "mat4d"
|
|
|
|
namespace tools {
|
|
|
|
class rotd : public qrot<vec3d,vec4d> {
|
|
typedef qrot<vec3d,vec4d> parent;
|
|
private:
|
|
rotd(double a_q0,double a_q1,double a_q2,double a_q3):parent(a_q0,a_q1,a_q2,a_q3){}
|
|
public:
|
|
rotd():parent() {} //zero rotation around the positive Z axis.
|
|
rotd(const vec3d& a_axis,double a_radians):parent(a_axis,a_radians,::sin,::cos) {}
|
|
rotd(const vec3d& a_from,const vec3d& a_to):parent(a_from,a_to,::sqrt,::fabs) {}
|
|
virtual ~rotd(){}
|
|
public:
|
|
rotd(const rotd& a_from):parent(a_from) {}
|
|
rotd& operator=(const rotd& a_from){
|
|
parent::operator=(a_from);
|
|
return *this;
|
|
}
|
|
public:
|
|
rotd& operator*=(const rotd& a_q) {
|
|
parent::operator*=(a_q);
|
|
return *this;
|
|
}
|
|
rotd operator*(const rotd& a_r) const {
|
|
rotd tmp(*this);
|
|
tmp *= a_r;
|
|
return tmp;
|
|
}
|
|
public:
|
|
bool set_value(const vec3d& a_from,const vec3d& a_to){
|
|
return parent::set_value(a_from,a_to,::sqrt,::fabs);
|
|
}
|
|
bool set_value(const vec3d& a_from,double a_a){
|
|
return parent::set_value(a_from,a_a,::sin,::cos);
|
|
}
|
|
bool value(vec3d& a_from,double& a_a) const {
|
|
return parent::value(a_from,a_a,::sin,::acos); //WARNING acos and not cos
|
|
}
|
|
|
|
//NOTE : don't handle a static object because of mem balance.
|
|
//static const rotd& identity() {
|
|
// static const rotd s_v(0,0,0,1);
|
|
// return s_v;
|
|
//}
|
|
|
|
void value(mat4d& a_m) const {parent::value(a_m);}
|
|
void set_value(const mat4d& a_m) {parent::set_value(a_m,::sqrt);}
|
|
|
|
double value(mat3d& a_m) const {return parent::value_3(a_m);}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|