Go to the documentation of this file.
18 static const std::string& s_class() {
19 static const std::string s_v(
"tools::vec3");
29 mem::increment(s_class().c_str());
37 mem::increment(s_class().c_str());
43 vec3(
const T& a0,
const T& a1,
const T& a2
49 if(a_inc) mem::increment(s_class().c_str());
57 mem::decrement(s_class().c_str());
63 mem::increment(s_class().c_str());
80 void v0(
const T& a_value) {
m_data[0] = a_value;}
81 void v1(
const T& a_value) {
m_data[1] = a_value;}
82 void v2(
const T& a_value) {
m_data[2] = a_value;}
92 void set_value(
const T& a0,
const T& a1,
const T& a2) {
102 void value(T& a0,T& a1,T& a2)
const {
120 if(norme==T())
return T();
144 template <
class PREC>
146 if(&a_v==
this)
return true;
147 for(
unsigned int index=0;index<3;index++) {
149 if(a_fabs(
diff)>=a_prec)
return false;
162 if(a_T==T())
return false;
181 void add(
const T& a0,
const T& a1,
const T& a2) {
193 void subtract(
const T& a0,
const T& a1,
const T& a2) {
201 T this_length =
length(a_sqrt);
202 if(this_length==T())
return false;
203 T a_v_length = a_v.
length(a_sqrt);
204 if(a_v_length==T())
return false;
205 a_cos =
dot(a_v)/(this_length*a_v_length);
209 bool theta_phi(T& a_theta,T& a_phi,T(*a_sqrt)(T),T(*a_atan2)(T,T))
const {
211 if(
length(a_sqrt)==T())
return false;
214 a_theta = a_atan2(xy,
m_data[2]);
254 if(a_v==T())
return vec3();
270 void setValue(
const T& a0,
const T& a1,
const T& a2) {
293 m_data[0] = a_bary[0]*a_v0[0]+a_bary[1]*a_v1[0]+a_bary[2]*a_v2[0];
294 m_data[1] = a_bary[0]*a_v0[1]+a_bary[1]*a_v1[1]+a_bary[2]*a_v2[1];
295 m_data[2] = a_bary[0]*a_v0[2]+a_bary[1]*a_v1[2]+a_bary[2]*a_v2[2];
300 #if defined(TOOLS_MEM) && !defined(TOOLS_MEM_ATEXIT)
302 static const vec3<T>&
s_y() {
static const vec3<T> s_v(0,1,0,
false);
return s_v;}
303 static const vec3<T>&
s_z() {
static const vec3<T> s_v(0,0,1,
false);
return s_v;}
312 private:
static void check_instantiation() {
vec3<float> v;}
331 a_tmp_1.
cross(a_tmp_2,a_nm);
343 template <
class VEC3>
344 inline void direction(
const VEC3& a_p0,
const VEC3& a_p1,
const VEC3& a_p2,VEC3& a_value) {
353 template <
class VEC3>
354 inline void area(
const VEC3& a_p0,
const VEC3& a_p1,
const VEC3& a_p2,
typename VEC3::elem_t& a_value,
355 VEC3& a_tmp_1,VEC3& a_tmp_2,VEC3& a_tmp_3) {
357 typedef typename VEC3::elem_t T;
360 a_tmp_1.subtract(a_p0);
363 a_tmp_2.subtract(a_p1);
365 a_tmp_1.cross(a_tmp_2,a_tmp_3);
367 a_value = a_tmp_3.length()/T(2);
370 template <
class VEC3>
371 inline void area(
const VEC3& a_p0,
const VEC3& a_p1,
const VEC3& a_p2,
typename VEC3::elem_t& a_value) {
373 area(a_p0,a_p1,a_p2,a_value,tmp1,tmp2,tmp3);
377 inline void direction(
const T& a_0_x,
const T& a_0_y,
const T& a_0_z,
378 const T& a_1_x,
const T& a_1_y,
const T& a_1_z,
379 const T& a_2_x,
const T& a_2_y,
const T& a_2_z,
vec3<T>& a_value) {
382 vec3<T>(a_2_x,a_2_y,a_2_z),a_value);
394 a_out <<
"x = " << a_this.
v0()
395 <<
",y = " << a_this.
v1()
396 <<
",z = " << a_this.
v2();