Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -122,7 +122,7 @@ public:
}
bool get_cube_size(T_t& a_dx,T_t& a_dy,T_t& a_dz,T_t(*a_sqrt)(T_t)) const {
if(!get_size(a_dx,a_dy,a_dz)) return false;
if(!get_size(a_dx,a_dy,a_dz)) return false;
if((a_dx<=zero())&&(a_dy<=zero())&&(a_dz<=zero())) return false;
if((a_dx<=zero())&&(a_dy<=zero())) { //dz not 0 :
a_dx = T_t(0.1)*a_dz;
@@ -44,7 +44,7 @@ inline bool is_inside(const VEC2& a_P,const std::vector<VEC2>& a_V) {
--wn; // have a valid down intersect
}
}
return ((wn!=0)?true:false);
}
@@ -85,7 +85,7 @@ inline bool inside(const std::pair<T,T>& a_P,const std::vector< std::pair<T,T> >
--wn; // have a valid down intersect
}
}
return ((wn!=0)?true:false);
}
@@ -98,7 +98,7 @@ inline bool intersect(const VEC2& P1,const VEC2& Q1,const VEC2& P2,const VEC2& Q
// (Q1-P1)*r - (Q2-P2)*s = P2-P1
// r*(Q1-P1).v0 - s*(Q2-P2).v0 = (P2-P1).v0 //x
// r*(Q1-P1).v1 - s*(Q2-P2).v1 = (P2-P1).v1 //y
// a*r + b*s = c
// d*r + e*s = f
@@ -75,8 +75,8 @@ protected:
// f(s) = a s**3 + b s**2 + c s + d
// f'(s) = 3 a s**2 + 2 b s + c
// f(0) = d = p0
// f'(0) = c = v0
// f(0) = d = p0
// f'(0) = c = v0
// f(1) = a + b + v0 + p0 = p1
// f'(1) = 3 a + 2 b + v0 = v1
@@ -91,7 +91,7 @@ protected:
T a_x = -2*a_p1_x + a_v0_x + 2*a_p0_x + a_v1_x;
T a_y = -2*a_p1_y + a_v0_y + 2*a_p0_y + a_v1_y;
T a_z = -2*a_p1_z + a_v0_z + 2*a_p0_z + a_v1_z;
m_a.set_value(a_x,a_y,a_z);
m_a.set_value(a_x,a_y,a_z);
T b_x = 3*(a_p1_x - a_v0_x - a_p0_x) - (a_v1_x - a_v0_x);
T b_y = 3*(a_p1_y - a_v0_y - a_p0_y) - (a_v1_y - a_v0_y);
@@ -151,10 +151,10 @@ public:
for(size_t i = 0; i < n; i++) {
VEC3 v0 = m_data[m_cur][i];
VEC3 v1 = m_data[m_cur][i+1];
T d0 = plane.distance(v0);
T d1 = plane.distance(v1);
if (d0 >= 0.0f && d1 < 0.0f) { // exit plane
VEC3 dir = v1-v0;
// we know that v0 != v1 since we got here
@@ -182,7 +182,7 @@ public:
protected:
void out_point(const VEC3& a_p) {m_data[m_cur ^ 1].push_back(a_p);}
protected:
std::vector<VEC3> m_data[2];
unsigned int m_cur;
@@ -95,24 +95,24 @@ public:
VEC3 D0 = m_dir;
VEC3 D1 = a_line.m_dir;
VEC3 D0N = D0;
T c[3], d[3];
for(unsigned int i=0;i<3;i++) {
d[i] = D1[i] - D0N[i]*(D0[0]*D1[0] + D0[1]*D1[1] + D0[2]*D1[2]);
c[i] = P1[i] - P0[i] + D0N[i]*(D0[0]*P0[0] + D0[1]*P0[1] + D0[2]*P0[2]);
}
T den = d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
if(den==T()) return false;
T t = -(c[0]*d[0]+c[1]*d[1]+c[2]*d[2]) / den;
a_on_line = a_line.m_pos + a_line.m_dir * t;
closest_point(a_on_line,a_on_this);
return true;
}
bool intersect(const line<T>& a_line,VEC3& a_out,const T& a_prec) const {
VEC3 p,q;
if(!closest_points(a_line,p,q)) return false;
@@ -121,7 +121,7 @@ public:
return true;
}
*/
protected:
VEC3 m_pos;
VEC3 m_dir; //normalized.
+14 -14
View File
@@ -33,7 +33,7 @@ public:
mat(
#ifdef TOOLS_MEM
bool a_inc = true
#endif
#endif
) {
#ifdef TOOLS_MEM
if(a_inc) mem::increment(s_class().c_str());
@@ -155,7 +155,7 @@ protected:
private:static void check_instantiation() {nmat<float> dummy(2);}
};
template <class T,unsigned int D>
template <class T,unsigned int D>
inline nmat<T> copy(const mat<T,D>& a_from) {
unsigned int D2 = D*D;
nmat<T> v(D);
@@ -182,7 +182,7 @@ inline void multiply(VECTOR& a_vec,const typename VECTOR::value_type::elem_t& a_
/// related to complex numbers : //////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
template <class MAT>
template <class MAT>
inline void conjugate(MAT& a_m,typename MAT::elem_t (*a_conj)(const typename MAT::elem_t&)) {
typedef typename MAT::elem_t T;
T* pos = const_cast<T*>(a_m.data());
@@ -192,7 +192,7 @@ inline void conjugate(MAT& a_m,typename MAT::elem_t (*a_conj)(const typename MAT
}
}
template <class MAT>
template <class MAT>
inline bool is_real(MAT& a_m,typename MAT::elem_t::value_type (*a_imag)(const typename MAT::elem_t&)) {
typedef typename MAT::elem_t T;
T* pos = const_cast<T*>(a_m.data());
@@ -201,7 +201,7 @@ inline bool is_real(MAT& a_m,typename MAT::elem_t::value_type (*a_imag)(const ty
return true;
}
template <class MAT,class PREC>
template <class MAT,class PREC>
inline bool is_real_prec(MAT& a_m,typename MAT::elem_t::value_type (*a_imag)(const typename MAT::elem_t&),
const PREC& a_prec,PREC(*a_fabs)(const typename MAT::elem_t::value_type&)) {\
typedef typename MAT::elem_t T;
@@ -220,7 +220,7 @@ inline bool is_imag(MAT& a_m,typename MAT::elem_t::value_type (*a_real)(const ty
return true;
}
template <class CMAT,class RMAT>
template <class CMAT,class RMAT>
inline bool to_real(const CMAT& a_c,RMAT& a_r,typename CMAT::elem_t::value_type (*a_real)(const typename CMAT::elem_t&)) {
if(a_r.dimension()!=a_c.dimension()) return false;
typedef typename CMAT::elem_t CT;
@@ -232,7 +232,7 @@ inline bool to_real(const CMAT& a_c,RMAT& a_r,typename CMAT::elem_t::value_type
return true;
}
template <class RMAT,class CMAT>
template <class RMAT,class CMAT>
inline bool to_complex(const RMAT& a_r,CMAT& a_c) {
if(a_c.dimension()!=a_r.dimension()) return false;
typedef typename RMAT::elem_t RT;
@@ -244,7 +244,7 @@ inline bool to_complex(const RMAT& a_r,CMAT& a_c) {
return true;
}
template <class MAT>
template <class MAT>
inline void dagger(MAT& a_m,typename MAT::elem_t (*a_conj)(const typename MAT::elem_t&)) {
conjugate<MAT>(a_m,a_conj);
a_m.transpose();
@@ -259,17 +259,17 @@ inline bool decomplex(const CMAT& a_c,RMAT& a_r,
// | -Y X |
typedef typename CMAT::elem_t CT; //std::complex<double>
typedef typename RMAT::elem_t RT; //double
unsigned int cdim = a_c.dimension();
if(a_r.dimension()!=2*cdim) {a_r.set_zero();return false;}
RT value;unsigned int r,c;
if(a_r.dimension()!=2*cdim) {a_r.set_zero();return false;}
RT value;unsigned int r,c;
for(r=0;r<cdim;r++) {
for(c=0;c<cdim;c++) {
const CT& cvalue = a_c.value(r,c);
value = a_real(cvalue);
value = a_real(cvalue);
a_r.set_value(r,c,value);
a_r.set_value(r+cdim,c+cdim,value);
value = a_imag(cvalue);
value = a_imag(cvalue);
a_r.set_value(r,c+cdim,value);
a_r.set_value(r+cdim,c,-value);
}
@@ -466,7 +466,7 @@ inline nmat<T> operator*(const nmat<T>& a_m,const T& a_fac) {
}
*/
template <class MAT,class REAL>
template <class MAT,class REAL>
inline bool mat_fabs(const MAT& a_in,MAT& a_ou,REAL(*a_fabs)(const typename MAT::elem_t&)) {
if(a_in.dimension()!=a_ou.dimension()) {a_ou.set_zero();return false;}
typedef typename MAT::elem_t T;
+24 -15
View File
@@ -84,12 +84,12 @@ public:
//NOTE : Z(x,y, z,1) = -2z/(f-n)+tz = [-2z-f-n]/(f-n)
// W(x,y, z,1) = 1 -> Z/W = Z
// Z(x,y,-n,1) = -1
// Z(x,y,-f,1) = 1
// Z(x,y,-n,1) = -1
// Z(x,y,-f,1) = 1
// Z(x,y,-(f+n)/2,1) = 0
// X(x,0, z,1) = 2x/(r-l)+tx = [2x-r-l]/(r-l)
// X(x,0, z,1) = 2x/(r-l)+tx = [2x-r-l]/(r-l)
// X(r,0, z,1) = 1
// the view direction is then (0,0,1) in the final projection.
@@ -124,7 +124,7 @@ public:
// Z(x,y,-2fn/(f+n),1) = 0
// -> Z/W = 0
// Z(x,y,-f,1) = -[-ff-fn+2fn]/(f-n) = -[fn-ff]/(f-n) = f
// W(x,y,-f,1) = f
// -> Z/W(x,y,-f,1) = 1
@@ -152,6 +152,12 @@ public:
a_z = pr::m_vec[14];
}
void no_translate() {
pr::m_vec[12] = 0;
pr::m_vec[13] = 0;
pr::m_vec[14] = 0;
}
//void set_translate_only(const T& a_x,const T& a_y,const T& a_z) {
// pr::m_vec[12] = a_x;
// pr::m_vec[13] = a_y;
@@ -352,8 +358,8 @@ protected:
static void _set_rotate(const T& a_x,const T& a_y,const T& a_z,const T& a_angle,T v[],T(*a_sin)(T),T(*a_cos)(T)) {
//WARNING : (a_x,a_y,a_z) must be a normalized vector.
// v[] = exp(-a_angle*n(a_x,a_y,a_z)*Rs). It models the rotation of an object in the same coordinate system (active rotation).
T si = a_sin(a_angle);
T co = a_cos(a_angle);
T si = a_sin(a_angle);
T co = a_cos(a_angle);
T x = a_x;
T y = a_y;
T z = a_z;
@@ -394,7 +400,7 @@ public:
//pr::m_vec[1] = 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
//pr::m_vec[2] = 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
//pr::m_vec[3] = 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
T tv_0 = tv[0];
T tv_1 = tv[1];
T tv_2 = tv[2];
@@ -453,6 +459,13 @@ public:
tv[15] = tv_15;
}
template <class MAT3>
void set_mat3(MAT3& a_m3) {
a_m3.set_matrix(pr::m_vec[0],pr::m_vec[4],pr::m_vec[ 8], //1 row
pr::m_vec[1],pr::m_vec[5],pr::m_vec[ 9], //2 row
pr::m_vec[2],pr::m_vec[6],pr::m_vec[10]); //3 row
}
private:static void check_instantiation() {mat4<float> dummy;}
};
@@ -489,14 +502,10 @@ namespace tools {
template <class T>
inline std::ostream& operator<<(std::ostream& a_out,const mat4<T>& a_mtx){
const T* v = a_mtx.data();
a_out << v[0] << "," << v[4] << "," << v[ 8] << "," << v[12]
<< std::endl
<< v[1] << "," << v[5] << "," << v[ 9] << "," << v[13]
<< std::endl
<< v[2] << "," << v[6] << "," << v[10] << "," << v[14]
<< std::endl
<< v[3] << "," << v[7] << "," << v[11] << "," << v[15]
<< std::endl;
a_out << v[0] << "," << v[4] << "," << v[ 8] << "," << v[12] << std::endl
<< v[1] << "," << v[5] << "," << v[ 9] << "," << v[13] << std::endl
<< v[2] << "," << v[6] << "," << v[10] << "," << v[14] << std::endl
<< v[3] << "," << v[7] << "," << v[11] << "," << v[15] << std::endl;
return a_out;
}
@@ -19,16 +19,16 @@ public:
// Construct a plane given 3 points.
// Orientation is computed by taking (p1 - p0) x (p2 - p0) and
// pointing the normal in that direction.
VEC3 P = a_p1;
P.subtract(a_p0);
VEC3 P2 = a_p2;
P2.subtract(a_p0);
P.cross(P2,m_normal);
if(!m_normal.normalize()) {} //throw
m_distance =
m_normal.v0() * a_p0.v0() +
m_normal.v1() * a_p0.v1() +
m_distance =
m_normal.v0() * a_p0.v0() +
m_normal.v1() * a_p0.v1() +
m_normal.v2() * a_p0.v2();
}
@@ -59,7 +59,7 @@ public:
// Offset a plane by a given distance.
m_distance += a_distance;
}
bool intersect(const line<VEC3>& a_line,VEC3& a_intersection) const {
// Intersect line and plane, returning true if there is an intersection
// false if line is parallel to plane
@@ -74,7 +74,7 @@ public:
//a_intersection = pos + t * dir;
return true;
}
bool is_in_half_space(const VEC3& a_point) const {
// Returns true if the given point is within the half-space
// defined by the plane
@@ -84,11 +84,11 @@ public:
pos.add(a_point);
return (m_normal.dot(pos) >= T() ? true : false);
}
const VEC3& normal() const {return m_normal;}
T distance_from_origin() const {return m_distance;}
T distance(const VEC3& a_point) const {
// Return the distance from point to plane. Positive distance means
// the point is in the plane's half space.
@@ -106,9 +106,9 @@ public:
// Orientation is given by the normal vector n.
m_normal = a_normal;
if(!m_normal.normalize()) {} //throw
m_distance =
m_normal.v0() * a_point.v0() +
m_normal.v1() * a_point.v1() +
m_distance =
m_normal.v0() * a_point.v0() +
m_normal.v1() * a_point.v1() +
m_normal.v2() * a_point.v2();
}
+25 -25
View File
@@ -96,12 +96,12 @@ public:
// Optimize by doing 1 div and 4 muls instead of 4 divs.
T inv = one() / length;
a_r.m_quat.set_value(-m_quat.v0() * inv,
-m_quat.v1() * inv,
-m_quat.v2() * inv,
m_quat.v3() * inv);
return true;
}
@@ -124,7 +124,7 @@ public:
bool set_value(const VEC3& a_from,const VEC3& a_to,T(*a_sqrt)(T),T(*a_fabs)(T)) {
// code taken from coin3d/SbRotation.
//NOTE : coin3d/SbMatrix logic is transposed relative to us.
VEC3 from(a_from);
if(from.normalize()==T()) return false;
VEC3 to(a_to);
@@ -210,10 +210,10 @@ public:
unsigned int k = (j+1)%3;
T _s = a_sqrt((a_m.value(i,i) - (a_m.value(j,j) + a_m.value(k,k))) + a_m.v33());
m_quat.set_value(i,_s * half());
_s = half() / _s;
m_quat.v3((a_m.value(k,j) - a_m.value(j,k)) * _s);
m_quat.set_value(j,(a_m.value(j,i) + a_m.value(i,j)) * _s);
m_quat.set_value(k,(a_m.value(k,i) + a_m.value(i,k)) * _s);
@@ -228,7 +228,7 @@ public:
void value(MAT4& a_m) const {
//Return this rotation in the form of a matrix.
//NOTE : in coin3d/SbRotation, it looks as if "w <-> -w", but coin3d/SbMatrix logic is transposed relative to us.
const T x = m_quat.v0();
const T y = m_quat.v1();
const T z = m_quat.v2();
@@ -240,19 +240,19 @@ public:
a_m.v01(2*x*y - 2*w*z);
a_m.v02(2*x*z + 2*w*y);
a_m.v03(0);
// second row :
a_m.v10(2*x*y + 2*w*z);
a_m.v11(w*w - x*x + y*y - z*z);
a_m.v12(2*y*z - 2*w*x);
a_m.v13(0);
// third row :
a_m.v20(2*x*z - 2*w*y);
a_m.v21(2*y*z + 2*w*x);
a_m.v22(w*w - x*x - y*y + z*z);
a_m.v23(0);
// fourth row :
a_m.v30(0);
a_m.v31(0);
@@ -264,7 +264,7 @@ public:
T value_3(MAT3& a_m) const {
//Return this rotation in the form of a 3D matrix.
//NOTE : in coin3d/SbRotation, it looks as if "w <-> -w", but coin3d/SbMatrix logic is transposed relative to us.
const T x = m_quat.v0();
const T y = m_quat.v1();
const T z = m_quat.v2();
@@ -275,17 +275,17 @@ public:
a_m.v00(w*w + x*x - y*y - z*z);
a_m.v01(2*x*y - 2*w*z);
a_m.v02(2*x*z + 2*w*y);
// second row :
a_m.v10(2*x*y + 2*w*z);
a_m.v11(w*w - x*x + y*y - z*z);
a_m.v12(2*y*z - 2*w*x);
// third row :
a_m.v20(2*x*z - 2*w*y);
a_m.v21(2*y*z + 2*w*x);
a_m.v22(w*w - x*x - y*y + z*z);
// fourth row :
//a_m.v30(0);
//a_m.v31(0);
@@ -299,20 +299,20 @@ public:
const T y = m_quat.v1();
const T z = m_quat.v2();
const T w = m_quat.v3();
// first row :
T v0 = (w*w + x*x - y*y - z*z) * a_in.v0()
+ (2*x*y - 2*w*z) * a_in.v1()
+ (2*x*z + 2*w*y) * a_in.v2();
T v1 = (2*x*y + 2*w*z) * a_in.v0()
+(w*w - x*x + y*y - z*z) * a_in.v1()
+ (2*y*z - 2*w*x) * a_in.v2();
T v2 = (2*x*z - 2*w*y) * a_in.v0()
+ (2*y*z + 2*w*x) * a_in.v1()
+(w*w - x*x - y*y + z*z) * a_in.v2();
a_out.set_value(v0,v1,v2);
}
@@ -321,20 +321,20 @@ public:
const T y = m_quat.v1();
const T z = m_quat.v2();
const T w = m_quat.v3();
// first row :
T v0 = (w*w + x*x - y*y - z*z) * a_v.v0()
+ (2*x*y - 2*w*z) * a_v.v1()
+ (2*x*z + 2*w*y) * a_v.v2();
T v1 = (2*x*y + 2*w*z) * a_v.v0()
+(w*w - x*x + y*y - z*z) * a_v.v1()
+ (2*y*z - 2*w*x) * a_v.v2();
T v2 = (2*x*z - 2*w*y) * a_v.v0()
+ (2*y*z + 2*w*x) * a_v.v1()
+(w*w - x*x - y*y + z*z) * a_v.v2();
a_v.set_value(v0,v1,v2);
}
@@ -343,20 +343,20 @@ public:
const T y = m_quat.v1();
const T z = m_quat.v2();
const T w = m_quat.v3();
// first row :
T v0 = (w*w + x*x - y*y - z*z) * a_x
+ (2*x*y - 2*w*z) * a_y
+ (2*x*z + 2*w*y) * a_z;
T v1 = (2*x*y + 2*w*z) * a_x
+(w*w - x*x + y*y - z*z) * a_y
+ (2*y*z - 2*w*x) * a_z;
T v2 = (2*x*z - 2*w*y) * a_x
+ (2*y*z + 2*w*x) * a_y
+(w*w - x*x - y*y + z*z) * a_z;
a_x = v0;
a_y = v1;
a_z = v2;
+13 -13
View File
@@ -86,9 +86,9 @@ public:
void value(T& a0,T& a1) const {
a0 = m_data[0];
a1 = m_data[1];
}
}
//bool set_value(unsigned int a_index,const T& a_value) {
//bool set_value(unsigned int a_index,const T& a_value) {
// if(a_index>=2) return false;
// m_[a_index] = a_value;
// return true;
@@ -106,13 +106,13 @@ public:
}
T dot(const vec2& aV) const {
return (m_data[0] * aV.m_data[0] +
return (m_data[0] * aV.m_data[0] +
m_data[1] * aV.m_data[1]);
}
}
T cross(const vec2& aV) const {
return (m_data[0] * aV.m_data[1] - m_data[1] * aV.m_data[0]);
}
}
bool equal(const vec2& aV) const {
if(m_data[0]!=aV.m_data[0]) return false;
@@ -130,22 +130,22 @@ public:
void add(const vec2& a_v) {
m_data[0] += a_v.m_data[0];
m_data[1] += a_v.m_data[1];
}
}
void add(const T& a0,const T& a1) {
m_data[0] += a0;
m_data[1] += a1;
}
}
void subtract(const vec2& a_v) {
m_data[0] -= a_v.m_data[0];
m_data[1] -= a_v.m_data[1];
}
}
void subtract(const T& a0,const T& a1) {
m_data[0] -= a0;
m_data[1] -= a1;
}
}
public: //operators
T& operator[](size_t a_index) {
@@ -160,17 +160,17 @@ public: //operators
vec2 operator+(const vec2& a_v) const {
return vec2(m_data[0]+a_v.m_data[0],
m_data[1]+a_v.m_data[1]);
}
}
vec2 operator-(const vec2& a_v) const {
return vec2(m_data[0]-a_v.m_data[0],
m_data[1]-a_v.m_data[1]);
}
}
vec2 operator*(const T& a_v) const {
return vec2(m_data[0]*a_v,
m_data[1]*a_v);
}
}
bool operator==(const vec2& a_v) const {return equal(a_v);}
bool operator!=(const vec2& a_v) const {return !operator==(a_v);}
@@ -184,7 +184,7 @@ public: //for iv2sg
void getValue(T& a0,T& a1) const {
a0 = m_data[0];
a1 = m_data[1];
}
}
void setValue(const T& a0,const T& a1) {
m_data[0] = a0;
m_data[1] = a1;
@@ -32,25 +32,25 @@ public: //operators
vec2f operator*(float a_v) const {
return vec2f(m_data[0]*a_v,
m_data[1]*a_v);
}
}
vec2f operator+(const vec2f& a_v) const {
return vec2f(m_data[0]+a_v.m_data[0],
m_data[1]+a_v.m_data[1]);
}
}
vec2f operator-(const vec2f& a_v) const {
return vec2f(m_data[0]-a_v.m_data[0],
m_data[1]-a_v.m_data[1]);
}
vec2f& operator+=(const vec2f& a_v) {
}
vec2f& operator+=(const vec2f& a_v) {
m_data[0] += a_v.m_data[0];
m_data[1] += a_v.m_data[1];
return *this;
}
vec2f& operator*=(float a_v) {
}
vec2f& operator*=(float a_v) {
m_data[0] *= a_v;
m_data[1] *= a_v;
return *this;
}
}
vec2f operator-() const {
return vec2f(-m_data[0],-m_data[1]);
}
@@ -80,7 +80,7 @@ public: //iv2sg
void negate() {
m_data[0] = -m_data[0];
m_data[1] = -m_data[1];
}
}
private:static void check_instantiation() {vec2f v(0,0);v.set_value(1,1);}
};
+18 -18
View File
@@ -43,7 +43,7 @@ public:
vec3(const T& a0,const T& a1,const T& a2
#ifdef TOOLS_MEM
,bool a_inc = true
#endif
#endif
) {
#ifdef TOOLS_MEM
if(a_inc) mem::increment(s_class().c_str());
@@ -103,9 +103,9 @@ public:
a0 = m_data[0];
a1 = m_data[1];
a2 = m_data[2];
}
}
//bool set_value(unsigned int a_index,const T& a_value) {
//bool set_value(unsigned int a_index,const T& a_value) {
// if(a_index>=3) return false;
// m_[a_index] = a_value;
// return true;
@@ -123,16 +123,16 @@ public:
}
T dot(const vec3& aV) const {
return (m_data[0] * aV.m_data[0] +
m_data[1] * aV.m_data[1] +
return (m_data[0] * aV.m_data[0] +
m_data[1] * aV.m_data[1] +
m_data[2] * aV.m_data[2]);
}
}
void cross(const vec3<T>& aV,vec3<T>& a_value) const {
a_value.set_value(m_data[1] * aV.m_data[2] - m_data[2] * aV.m_data[1],
m_data[2] * aV.m_data[0] - m_data[0] * aV.m_data[2],
m_data[0] * aV.m_data[1] - m_data[1] * aV.m_data[0]);
}
}
bool equal(const vec3& aV) const {
if(m_data[0]!=aV.m_data[0]) return false;
@@ -156,7 +156,7 @@ public:
return vec3<T>(m_data[1] * aV.m_data[2] - m_data[2] * aV.m_data[1],
m_data[2] * aV.m_data[0] - m_data[0] * aV.m_data[2],
m_data[0] * aV.m_data[1] - m_data[1] * aV.m_data[0]);
}
}
bool divide(const T& a_T) {
if(a_T==T()) return false;
@@ -176,25 +176,25 @@ public:
m_data[0] += a_v.m_data[0];
m_data[1] += a_v.m_data[1];
m_data[2] += a_v.m_data[2];
}
}
void add(const T& a0,const T& a1,const T& a2) {
m_data[0] += a0;
m_data[1] += a1;
m_data[2] += a2;
}
}
void subtract(const vec3& a_v) {
m_data[0] -= a_v.m_data[0];
m_data[1] -= a_v.m_data[1];
m_data[2] -= a_v.m_data[2];
}
}
void subtract(const T& a0,const T& a1,const T& a2) {
m_data[0] -= a0;
m_data[1] -= a1;
m_data[2] -= a2;
}
}
bool cos_angle(const vec3& a_v,T& a_cos,T(*a_sqrt)(T)) const {
//WARNING : if ret false, a_cos is not set.
@@ -206,7 +206,7 @@ public:
return true;
}
bool theta_phi(T& a_theta,T& a_phi,T(*a_sqrt)(T),T(*a_atan2)(T,T)) const {
bool theta_phi(T& a_theta,T& a_phi,T(*a_sqrt)(T),T(*a_atan2)(T,T)) const {
//WARNING : if ret false, a_theta, a_phi are not set.
if(length(a_sqrt)==T()) return false;
a_phi = a_atan2(m_data[1],m_data[0]);
@@ -236,26 +236,26 @@ public: //operators
return vec3(m_data[0]+a_v.m_data[0],
m_data[1]+a_v.m_data[1],
m_data[2]+a_v.m_data[2]);
}
}
vec3 operator-(const vec3& a_v) const {
return vec3(m_data[0]-a_v.m_data[0],
m_data[1]-a_v.m_data[1],
m_data[2]-a_v.m_data[2]);
}
}
vec3 operator*(const T& a_v) const {
return vec3(m_data[0]*a_v,
m_data[1]*a_v,
m_data[2]*a_v);
}
}
vec3 operator/(const T& a_v) const {
if(a_v==T()) return vec3();
return vec3(m_data[0]/a_v,
m_data[1]/a_v,
m_data[2]/a_v);
}
}
bool operator==(const vec3& a_v) const {return equal(a_v);}
bool operator!=(const vec3& a_v) const {return !operator==(a_v);}
@@ -276,7 +276,7 @@ public: //for iv2sg
a0 = m_data[0];
a1 = m_data[1];
a2 = m_data[2];
}
}
void setValue(const vec3& a_v) {
m_data[0] = a_v.m_data[0];
m_data[1] = a_v.m_data[1];
@@ -33,35 +33,35 @@ public: //operators
return vec3d(m_data[0]*a_v,
m_data[1]*a_v,
m_data[2]*a_v);
}
}
vec3d operator+(const vec3d& a_v) const {
return vec3d(m_data[0]+a_v.m_data[0],
m_data[1]+a_v.m_data[1],
m_data[2]+a_v.m_data[2]);
}
}
vec3d operator-(const vec3d& a_v) const {
return vec3d(m_data[0]-a_v.m_data[0],
m_data[1]-a_v.m_data[1],
m_data[2]-a_v.m_data[2]);
}
vec3d& operator+=(const vec3d& a_v) {
}
vec3d& operator+=(const vec3d& a_v) {
m_data[0] += a_v.m_data[0];
m_data[1] += a_v.m_data[1];
m_data[2] += a_v.m_data[2];
return *this;
}
}
vec3d& operator-=(const vec3d& a_v) {
m_data[0] -= a_v.m_data[0];
m_data[1] -= a_v.m_data[1];
m_data[2] -= a_v.m_data[2];
return *this;
}
vec3d& operator*=(double a_v) {
vec3d& operator*=(double a_v) {
m_data[0] *= a_v;
m_data[1] *= a_v;
m_data[2] *= a_v;
return *this;
}
}
vec3d operator-() const {
return vec3d(-m_data[0],-m_data[1],-m_data[2]);
}
@@ -33,17 +33,17 @@ public: //operators
return vec3f(m_data[0]*a_v,
m_data[1]*a_v,
m_data[2]*a_v);
}
}
vec3f operator+(const vec3f& a_v) const {
return vec3f(m_data[0]+a_v.m_data[0],
m_data[1]+a_v.m_data[1],
m_data[2]+a_v.m_data[2]);
}
}
vec3f operator-(const vec3f& a_v) const {
return vec3f(m_data[0]-a_v.m_data[0],
m_data[1]-a_v.m_data[1],
m_data[2]-a_v.m_data[2]);
}
}
vec3f& operator+=(const vec3f& a_v) {
m_data[0] += a_v.m_data[0];
m_data[1] += a_v.m_data[1];
@@ -56,12 +56,12 @@ public: //operators
m_data[2] -= a_v.m_data[2];
return *this;
}
vec3f& operator*=(float a_v) {
vec3f& operator*=(float a_v) {
m_data[0] *= a_v;
m_data[1] *= a_v;
m_data[2] *= a_v;
return *this;
}
}
vec3f operator-() const {
return vec3f(-m_data[0],-m_data[1],-m_data[2]);
}
@@ -107,7 +107,7 @@ public: //iv2sg
m_data[0] = -m_data[0];
m_data[1] = -m_data[1];
m_data[2] = -m_data[2];
}
}
private:static void check_instantiation() {vec3f v(0,0,0);v.set_value(1,1,1);}
};
@@ -49,7 +49,7 @@ public:
vec4(const T& a0,const T& a1,const T& a2,const T& a3
#ifdef TOOLS_MEM
,bool a_inc = true
#endif
#endif
) {
#ifdef TOOLS_MEM
if(a_inc) mem::increment(s_class().c_str());
@@ -114,9 +114,9 @@ public:
a1 = m_data[1];
a2 = m_data[2];
a3 = m_data[3];
}
}
bool set_value(unsigned int a_index,const T& a_value) {
bool set_value(unsigned int a_index,const T& a_value) {
if(a_index>=4) return false;
m_data[a_index] = a_value;
return true;
@@ -197,28 +197,28 @@ public:
m_data[1] += a_v.m_data[1];
m_data[2] += a_v.m_data[2];
m_data[3] += a_v.m_data[3];
}
}
void add(const T& a0,const T& a1,const T& a2,const T& a3) {
m_data[0] += a0;
m_data[1] += a1;
m_data[2] += a2;
m_data[3] += a3;
}
}
void subtract(const vec4& a_v) {
m_data[0] -= a_v.m_data[0];
m_data[1] -= a_v.m_data[1];
m_data[2] -= a_v.m_data[2];
m_data[3] -= a_v.m_data[3];
}
}
void subtract(const T& a0,const T& a1,const T& a2,const T& a3) {
m_data[0] -= a0;
m_data[1] -= a1;
m_data[2] -= a2;
m_data[3] -= a3;
}
}
public: //operators
T& operator[](size_t a_index) {
@@ -235,7 +235,7 @@ public: //operators
m_data[1]+a_v.m_data[1],
m_data[2]+a_v.m_data[2],
m_data[3]+a_v.m_data[3]);
}
}
vec4 operator-(const vec4& a_v) const {
return vec4(m_data[0]-a_v.m_data[0],
@@ -249,7 +249,7 @@ public: //operators
m_data[1]*a_v,
m_data[2]*a_v,
m_data[3]*a_v);
}
}
bool operator==(const vec4& a_v) const {return equal(a_v);}
bool operator!=(const vec4& a_v) const {return !operator==(a_v);}
@@ -35,33 +35,33 @@ public: //operators
m_data[1]*a_v,
m_data[2]*a_v,
m_data[3]*a_v);
}
}
vec4f operator+(const vec4f& a_v) const {
return vec4f(m_data[0]+a_v.m_data[0],
m_data[1]+a_v.m_data[1],
m_data[2]+a_v.m_data[2],
m_data[3]+a_v.m_data[3]);
}
}
vec4f operator-(const vec4f& a_v) const {
return vec4f(m_data[0]-a_v.m_data[0],
m_data[1]-a_v.m_data[1],
m_data[2]-a_v.m_data[2],
m_data[3]-a_v.m_data[3]);
}
vec4f& operator+=(const vec4f& a_v) {
}
vec4f& operator+=(const vec4f& a_v) {
m_data[0] += a_v.m_data[0];
m_data[1] += a_v.m_data[1];
m_data[2] += a_v.m_data[2];
m_data[3] += a_v.m_data[3];
return *this;
}
vec4f& operator*=(float a_v) {
}
vec4f& operator*=(float a_v) {
m_data[0] *= a_v;
m_data[1] *= a_v;
m_data[2] *= a_v;
m_data[3] *= a_v;
return *this;
}
}
vec4f operator-() const {
return vec4f(-m_data[0],-m_data[1],-m_data[2],-m_data[3]);
}