Hugin trunk 0.1
Loading...
Searching...
No Matches
Vector3.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
24#include <math.h>
25
26#include "Vector3.h"
27
28
30void Vector3::Set(double a, double b, double c) { x=a; y=b; z=c; }
31
33bool Vector3::IsZero() const
34{
35 return ((x==0.f) && (y==0.f) && (z==0.f));
36}
37
40{
41 return ( (fabs(x)<EPSILON) && (fabs(y)<EPSILON) && (fabs(z)<EPSILON) );
42}
43
46{
47 return ( (fabs(x-v.x)<EPSILON) && (fabs(y-v.y)<EPSILON) && (fabs(z-v.z)<EPSILON) );
48}
49
52{
53 double invScale = 1.f/Scale;
54 return Vector3( x * invScale, y * invScale, z * invScale );
55}
56
59{
60 double invScale = 1.f/Scale;
61 x *= invScale;
62 y *= invScale;
63 z *= invScale;
64 return *this;
65}
66
68double Vector3::Norm() const
69{
70 return sqrt( x*x + y*y + z*z );
71}
72
75{
76 return x*x + y*y + z*z;
77}
78
81{
82 double SquareSum = x*x + y*y + z*z;
83 if( SquareSum >= EPSILON )
84 {
85 double invNorm = 1.f/sqrt(SquareSum);
86 x *= invNorm;
87 y *= invNorm;
88 z *= invNorm;
89 return true;
90 }
91 return false;
92}
93
96{
97 Vector3 result(*this);
98 double SquareSum = x*x + y*y + z*z;
99 if( SquareSum >= EPSILON )
100 {
101 double invNorm = 1.f/sqrt(SquareSum);
102 result.x *= invNorm;
103 result.y *= invNorm;
104 result.z *= invNorm;
105 }
106 return result;
107}
108
#define EPSILON
Definition Vector3.h:32
general : Vector3 is a class for handling 3D Vectors manipulation.
Definition Vector3.h:44
Vector3()
default constructor
Definition Vector3.h:52
bool IsNearlyZero() const
comparison : nearly zero
Definition Vector3.cpp:39
Vector3 operator/=(double Scale)
double divide
Definition Vector3.cpp:58
void Set(double a, double b, double c)
set
Definition Vector3.cpp:30
double x
x,y,z coordinates, 0 at the initialisation
Definition Vector3.h:47
bool IsNearlyEqual(const Vector3 &v) const
comparison : nearly equal
Definition Vector3.cpp:45
Vector3 GetNormalized() const
return a normalized vector
Definition Vector3.cpp:95
double NormSquared() const
squared norm
Definition Vector3.cpp:74
double z
Definition Vector3.h:47
Vector3 operator/(double Scale) const
operator /(double)
Definition Vector3.cpp:51
bool Normalize()
Normalize.
Definition Vector3.cpp:80
bool IsZero() const
comparison : zero
Definition Vector3.cpp:33
double Norm() const
euclidien norm
Definition Vector3.cpp:68
double y
Definition Vector3.h:47
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41