57 if (val <
epsilon)
return false;
58 (*this) = (*this)/val;
79 const Real cos_angle = (
inner(*
this, vv))/ll;
81 if ( cos_angle >= cos_tol )
83 else if ( cos_angle <= -cos_tol )
114 return (
v[0] != 0.0 ||
v[1] != 0.0) ?
true :
false;
127 void store(FILE* fp,
const vec2& v)
129 fprintf(fp,
"(%lg", v[0]);
130 for(
int i = 1; i < 2;++i){
131 fprintf(fp,
" %lg", v[i]);
146 int apx_equal(
const vec2& a,
const vec2& b)
150 for (
int i = 0 ; i < 2 ;++i){
161 for (
int i = 0 ; i < 2 ;++i){
177 if (val <
epsilon)
return false;
178 (*this) = (*this)/val;
199 const Real cos_angle = (
inner(*
this, vv))/ll;
201 if ( cos_angle >= cos_tol )
203 else if ( cos_angle <= -cos_tol )
233 if ( fabs(vv[1]) > fabs(vv[0]) ) {
234 if ( fabs(vv[2]) > fabs(vv[1]) ) {
241 else if ( fabs(vv[2]) >= fabs(vv[0]) ){
257 else if ( fabs(vv[2]) > fabs(vv[0]) ) {
265 else if ( fabs(vv[2]) > fabs(vv[1]) ) {
285 return (a != 0.0) ?
true :
false;
290 const vec3& P0,
const vec3& P1,
const vec3& P2
294 vec3 V0, V1, V2, N0, N1, N2;
296 v[0] =
v[1] =
v[2] = 0.0;
302 N0 =
cross( V1, V2 );
307 N1 =
cross( V2, V0 );
312 N2 =
cross( V0, V1 );
317 const Real s0 = 1.0/V0.length();
318 const Real s1 = 1.0/V1.length();
319 const Real s2 = 1.0/V2.length();
344 void store(FILE* fp,
const vec3& v)
346 fprintf(fp,
"(%lg", v[0]);
347 for(
int i = 1; i < 3;++i){
348 fprintf(fp,
" %lg", v[i]);
363 int apx_equal(
const vec3& a,
const vec3& b)
367 for (
int i = 0 ; i < 3 ;++i){
378 for (
int i = 0 ; i < 3 ;++i){
393 if (val <
epsilon)
return false;
394 (*this) = (*this)/val;
403 void store(FILE* fp,
const vec4& v)
405 fprintf(fp,
"(%lg", v[0]);
406 for(
int i = 1; i < 4;++i){
407 fprintf(fp,
" %lg", v[i]);
422 int apx_equal(
const vec4& a,
const vec4& b)
426 for (
int i = 0 ; i < 4 ;++i){
437 for (
int i = 0 ; i < 4 ;++i){
444 vec3
cross(
const vec3& a,
const vec3& b)
448 c(0) = a(0 + 1) * b(0 + 2) - a(0 + 2) * b(0 + 1);
450 c(1) = a(1 + 1) * b(1 + 2) - a(1 + 2) * b(1 + 1);
452 c(2) = a(2 + 1) * b(2 + 2) - a(2 + 2) * b(2 + 1);
Real inner(const vec2 &a, const vec2 &b)
bool is_perpendicular(const vec3 &, Real=angle_tolerance) const
int is_parallel(const vec3 &, Real=angle_tolerance) const
int is_parallel(const vec2 &, Real=angle_tolerance) const
void store(FILE *fp, const vec2 &v)
int apx_equal(Real x, Real y)
vec3 cross(const vec3 &a, const vec3 &b)
bool perpendicular(const vec3 &)
bool perpendicular(const vec2 &)
bool is_perpendicular(const vec2 &, Real=angle_tolerance) const