1#ifndef __JBXL_CPP_T_VECTOR_H_
2#define __JBXL_CPP_T_VECTOR_H_
18#define TVECTOR TVector
32 TVector(T X=0, T Y=0, T Z=0, T W=0,
double N=0.0,
double C=1.0,
int D=0) { set(X, Y, Z, W, N, C, D);}
35 void set(T X, T Y=0, T Z=0, T W=0,
double N=0.0,
double C=1.0,
int D=0);
45template <
typename T>
void TVector<T>::set(T X, T Y, T Z, T W,
double N,
double C,
int D)
66 if (v2.
n>=tt) cc = (v1*v2)/(
double)(v2.
n*v2.
n);
70 if (dif.
n>=tolerance) {
74 t = (T)((v1.
n*v2.
t + v2.
n*v1.
t)/(v2.
n*v2.
n));
93 if (
Xabs(xx)<tt) xx = (T)0.0;
94 if (
Xabs(yy)<tt) yy = (T)0.0;
95 if (
Xabs(zz)<tt) zz = (T)0.0;
114 if (
Xabs(xx)<tt) xx = (T)0.0;
115 if (
Xabs(yy)<tt) yy = (T)0.0;
116 if (
Xabs(zz)<tt) zz = (T)0.0;
147 T dst = (v1.
x-v2.
x)*(v1.
x-v2.
x) + (v1.
y-v2.
y)*(v1.
y-v2.
y) + (v1.
z-v2.
z)*(v1.
z-v2.
z);
148 T err = (v1.
t+v2.
t)*(v1.
t+v2.
t);
149 if (dst<=err)
return true;
156 T dst = (v1.
x-v2.
x)*(v1.
x-v2.
x) + (v1.
y-v2.
y)*(v1.
y-v2.
y) + (v1.
z-v2.
z)*(v1.
z-v2.
z);
157 T err = (v1.
t+v2.
t)*(v1.
t+v2.
t);
158 if (dst>err)
return true;
166 T xx = a.
y*b.
z - a.
z*b.
y;
167 T yy = a.
z*b.
x - a.
x*b.
z;
168 T zz = a.
x*b.
y - a.
y*b.
x;
169 T tt = (T)(a.
n*b.
t + a.
t*b.
n);
170 if (
Xabs(xx)<tt) xx = (T)0.0;
171 if (
Xabs(yy)<tt) yy = (T)0.0;
172 if (
Xabs(zz)<tt) zz = (T)0.0;
179{
return (T)(a.
x*b.
x + a.
y*b.
y + a.
z*b.
z);}
184{
return (T)(a.
n*b.
t + a.
t*b.
n); }
void set(T X, T Y=0, T Z=0, T W=0, double N=0.0, double C=1.0, int D=0)
TVector(T X=0, T Y=0, T Z=0, T W=0, double N=0.0, double C=1.0, int D=0)
void set(T X, T Y=0, T Z=0, double N=0.0, double C=1.0, int D=0)
double ProportionVector(TVector< T > v1, TVector< T > v2, T &t)
T TVectorMultiTolerance(TVector< T > a, TVector< T > b)
内積の誤差
AffineTrans< T > operator*(AffineTrans< T > a, AffineTrans< T > b)
Matrix< T > operator+(const Matrix< T > a, const Matrix< T > b)
double Zero_Eps
1に対して 0とするトレランス
Matrix< T > operator/(const Matrix< T > a, const R d)
bool operator==(const Matrix< T > v1, const Matrix< T > v2)
bool operator!=(const Quaternion< T > q1, const Quaternion< T > q2)
~ 共役
TVector< T > operator^(const TVector< T > a, const TVector< T > b)
Cross product 外積
Matrix< T > operator-(const Matrix< T > a)