EMAN2
Public Member Functions | Private Attributes | List of all members
EMAN::Vector3 Class Reference

#include <vecmath.h>

Public Member Functions

 Vector3 ()
 
 Vector3 (const Vector3 &v)
 
 Vector3 (double _x, double _y, double _z)
 
Vector3operator= (const Vector3 &a)
 
const double & operator[] (int n) const
 
double & operator[] (int n)
 
Vector3operator+= (const Vector3 &a)
 
Vector3operator-= (const Vector3 &a)
 
Vector3operator*= (double s)
 
Vector3 operator- () const
 
Vector3 operator+ () const
 
Vector3 operator+ (const Vector3 &v) const
 
Vector3 operator- (const Vector3 &v) const
 
Vector3 operator/ (const double s) const
 
Vector3 operator* (const double s) const
 
double operator* (const Vector3 &v) const
 
Vector3 operator^ (const Vector3 &v) const
 
double length () const
 
double lengthSquared () const
 
void normalize ()
 
bool operator== (const Vector3 &v) const
 
bool operator!= (const Vector3 &v) const
 
bool approxEqual (const Vector3 &v, double eps=1e-12) const
 
void print () const
 

Private Attributes

double x
 
double y
 
double z
 

Detailed Description

Definition at line 202 of file vecmath.h.

Constructor & Destructor Documentation

◆ Vector3() [1/3]

EMAN::Vector3::Vector3 ( )
inline

Definition at line 204 of file vecmath.h.

204: x(0), y(0), z(0) {}
double x
Definition: vecmath.h:298
double z
Definition: vecmath.h:298
double y
Definition: vecmath.h:298

Referenced by operator*(), operator+(), operator-(), operator/(), and operator^().

◆ Vector3() [2/3]

EMAN::Vector3::Vector3 ( const Vector3 v)
inline

Definition at line 205 of file vecmath.h.

205: x(v[0]), y(v[1]), z(v[2]) {}

◆ Vector3() [3/3]

EMAN::Vector3::Vector3 ( double  _x,
double  _y,
double  _z 
)
inline

Definition at line 206 of file vecmath.h.

206: x(_x), y(_y), z(_z) {}

Member Function Documentation

◆ approxEqual()

bool EMAN::Vector3::approxEqual ( const Vector3 v,
double  eps = 1e-12 
) const
inline

Definition at line 289 of file vecmath.h.

289 {
290 return isZero( x - v.x, eps ) && isZero( y - v.y, eps ) && isZero( z - v.z, eps );
291 }
bool isZero(double in_d, double in_dEps=1e-16)
Definition: vecmath.h:44

References EMAN::isZero(), x, y, and z.

◆ length()

double EMAN::Vector3::length ( ) const
inline

Definition at line 268 of file vecmath.h.

268 {
269 return (double) sqrt(x * x + y * y + z * z);
270 }
EMData * sqrt() const
return square root of current image

References sqrt(), x, y, and z.

Referenced by EMAN::length(), and EMAN::unit().

◆ lengthSquared()

double EMAN::Vector3::lengthSquared ( ) const
inline

Definition at line 272 of file vecmath.h.

272 {
273 return x * x + y * y + z * z;
274 }

References x, y, and z.

◆ normalize()

void EMAN::Vector3::normalize ( )
inline

Definition at line 276 of file vecmath.h.

276 {
277 double s = 1.0 / (double) sqrt(x * x + y * y + z * z);
278 x *= s; y *= s; z *= s;
279 }

References sqrt(), x, y, and z.

Referenced by EMAN::Matrix4::rotation().

◆ operator!=()

bool EMAN::Vector3::operator!= ( const Vector3 v) const
inline

Definition at line 285 of file vecmath.h.

285 {
286 return x != v.x || y != v.y || z != v.z;
287 }

References x, y, and z.

◆ operator*() [1/2]

Vector3 EMAN::Vector3::operator* ( const double  s) const
inline

Definition at line 252 of file vecmath.h.

252 {
253 return Vector3( x * s, y * s, z * s );
254 }

References Vector3(), x, y, and z.

◆ operator*() [2/2]

double EMAN::Vector3::operator* ( const Vector3 v) const
inline

Definition at line 257 of file vecmath.h.

257 {
258 return x * v.x + y * v.y + z * v.z;
259 }

References x, y, and z.

◆ operator*=()

Vector3 & EMAN::Vector3::operator*= ( double  s)
inline

Definition at line 226 of file vecmath.h.

226 {
227 x *= s; y *= s; z *= s;
228 return *this;
229 }

References x, y, and z.

◆ operator+() [1/2]

Vector3 EMAN::Vector3::operator+ ( ) const
inline

Definition at line 235 of file vecmath.h.

235 {
236 return *this;
237 }

◆ operator+() [2/2]

Vector3 EMAN::Vector3::operator+ ( const Vector3 v) const
inline

Definition at line 239 of file vecmath.h.

239 {
240 return Vector3( x + v.x, y + v.y, z + v.z );
241 }

References Vector3(), x, y, and z.

◆ operator+=()

Vector3 & EMAN::Vector3::operator+= ( const Vector3 a)
inline

Definition at line 216 of file vecmath.h.

216 {
217 x += a[0]; y += a[1]; z += a[2];
218 return *this;
219 }

References x, y, and z.

◆ operator-() [1/2]

Vector3 EMAN::Vector3::operator- ( ) const
inline

Definition at line 231 of file vecmath.h.

231 {
232 return Vector3(-x, -y, -z);
233 }

References Vector3(), x, y, and z.

◆ operator-() [2/2]

Vector3 EMAN::Vector3::operator- ( const Vector3 v) const
inline

Definition at line 243 of file vecmath.h.

243 {
244 return Vector3( x - v.x, y - v.y, z - v.z );
245 }

References Vector3(), x, y, and z.

◆ operator-=()

Vector3 & EMAN::Vector3::operator-= ( const Vector3 a)
inline

Definition at line 221 of file vecmath.h.

221 {
222 x -= a[0]; y -= a[1]; z -= a[2];
223 return *this;
224 }

References x, y, and z.

◆ operator/()

Vector3 EMAN::Vector3::operator/ ( const double  s) const
inline

Definition at line 247 of file vecmath.h.

247 {
248 Assert( s > 0.0 );
249 return Vector3( x / s, y / s, z / s );
250 }
#define Assert(s)
Define Assert() function that is effective only when -DDEBUG is used.
Definition: emassert.h:42

References Assert, Vector3(), x, y, and z.

◆ operator=()

Vector3 & EMAN::Vector3::operator= ( const Vector3 a)
inline

Definition at line 208 of file vecmath.h.

208 {
209 x = a[0]; y = a[1]; z = a[2];
210 return *this;
211 }

References x, y, and z.

◆ operator==()

bool EMAN::Vector3::operator== ( const Vector3 v) const
inline

Definition at line 281 of file vecmath.h.

281 {
282 return x == v.x && y == v.y && z == v.z;
283 }

References x, y, and z.

◆ operator[]() [1/2]

double & EMAN::Vector3::operator[] ( int  n)
inline

Definition at line 214 of file vecmath.h.

214{ return (&x)[n]; }

References x.

◆ operator[]() [2/2]

const double & EMAN::Vector3::operator[] ( int  n) const
inline

Definition at line 213 of file vecmath.h.

213{ return (&x)[n]; }

References x.

◆ operator^()

Vector3 EMAN::Vector3::operator^ ( const Vector3 v) const
inline

Definition at line 262 of file vecmath.h.

262 {
263 return Vector3( y * v.z - z * v.y,
264 z * v.x - x * v.z,
265 x * v.y - y * v.x );
266 }

References Vector3(), x, y, and z.

◆ print()

void EMAN::Vector3::print ( ) const
inline

Definition at line 293 of file vecmath.h.

293 {
294 std::cout << x << " " << y << " " << z << "\n";
295 }

References x, y, and z.

Member Data Documentation

◆ x

double EMAN::Vector3::x
private

◆ y

double EMAN::Vector3::y
private

◆ z

double EMAN::Vector3::z
private

The documentation for this class was generated from the following file: