EMAN2
Public Member Functions | Private Attributes
EMAN::Vector3 Class Reference

#include <vecmath.h>

List of all members.

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 206 of file vecmath.h.


Constructor & Destructor Documentation

EMAN::Vector3::Vector3 ( ) [inline]

Definition at line 208 of file vecmath.h.

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

: x(0), y(0), z(0) {}
EMAN::Vector3::Vector3 ( const Vector3 v) [inline]

Definition at line 209 of file vecmath.h.

: x(v[0]), y(v[1]), z(v[2]) {}
EMAN::Vector3::Vector3 ( double  _x,
double  _y,
double  _z 
) [inline]

Definition at line 210 of file vecmath.h.

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

Member Function Documentation

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

Definition at line 293 of file vecmath.h.

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

                                                                           {
                return isZero( x - v.x, eps ) && isZero( y - v.y, eps ) && isZero( z - v.z, eps );
            }
double EMAN::Vector3::length ( ) const [inline]

Definition at line 272 of file vecmath.h.

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

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

                                  {
                return (double) sqrt(x * x + y * y + z * z);
            }
double EMAN::Vector3::lengthSquared ( ) const [inline]

Definition at line 276 of file vecmath.h.

References x, y, and z.

                                         {
                return x * x + y * y + z * z;
            }
void EMAN::Vector3::normalize ( ) [inline]

Definition at line 280 of file vecmath.h.

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

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

                             {
                double s = 1.0 / (double) sqrt(x * x + y * y + z * z);
                x *= s; y *= s; z *= s;
            }
bool EMAN::Vector3::operator!= ( const Vector3 v) const [inline]

Definition at line 289 of file vecmath.h.

References x, y, and z.

                                                      {
                return x != v.x || y != v.y || z != v.z;
            }
Vector3 EMAN::Vector3::operator* ( const double  s) const [inline]

Definition at line 256 of file vecmath.h.

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

                                                      {
                return Vector3( x * s, y * s, z * s );
            }
double EMAN::Vector3::operator* ( const Vector3 v) const [inline]

Definition at line 261 of file vecmath.h.

References x, y, and z.

                                                       {
                return x * v.x + y * v.y + z * v.z;
            }
Vector3& EMAN::Vector3::operator*= ( double  s) [inline]

Definition at line 230 of file vecmath.h.

References x, y, and z.

                                          {
                x *= s; y *= s; z *= s;
                return *this;
            }
Vector3 EMAN::Vector3::operator+ ( ) const [inline]

Definition at line 239 of file vecmath.h.

                                      {
                return *this;
            }
Vector3 EMAN::Vector3::operator+ ( const Vector3 v) const [inline]

Definition at line 243 of file vecmath.h.

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

                                                        {
                return Vector3( x + v.x, y + v.y, z + v.z );
            }
Vector3& EMAN::Vector3::operator+= ( const Vector3 a) [inline]

Definition at line 220 of file vecmath.h.

References x, y, and z.

                                                  {
                x += a[0]; y += a[1]; z += a[2];
                return *this;
            }
Vector3 EMAN::Vector3::operator- ( const Vector3 v) const [inline]

Definition at line 247 of file vecmath.h.

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

                                                        {
                return Vector3( x - v.x, y - v.y, z - v.z );
            }
Vector3 EMAN::Vector3::operator- ( ) const [inline]

Definition at line 235 of file vecmath.h.

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

                                      {
                return Vector3(-x, -y, -z);
            }
Vector3& EMAN::Vector3::operator-= ( const Vector3 a) [inline]

Definition at line 225 of file vecmath.h.

References x, y, and z.

                                                  {
                x -= a[0]; y -= a[1]; z -= a[2];
                return *this;
            }
Vector3 EMAN::Vector3::operator/ ( const double  s) const [inline]

Definition at line 251 of file vecmath.h.

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

                                                      {
                Assert( s > 0.0 );
                return Vector3( x / s, y / s, z / s );
            }
Vector3& EMAN::Vector3::operator= ( const Vector3 a) [inline]

Definition at line 212 of file vecmath.h.

References x, y, and z.

                                                 {
                x = a[0]; y = a[1]; z = a[2];
                return *this;
            }
bool EMAN::Vector3::operator== ( const Vector3 v) const [inline]

Definition at line 285 of file vecmath.h.

References x, y, and z.

                                                      {
                return x == v.x && y == v.y && z == v.z;
            }
const double& EMAN::Vector3::operator[] ( int  n) const [inline]

Definition at line 217 of file vecmath.h.

References x.

{ return (&x)[n]; }
double& EMAN::Vector3::operator[] ( int  n) [inline]

Definition at line 218 of file vecmath.h.

References x.

{ return (&x)[n]; }
Vector3 EMAN::Vector3::operator^ ( const Vector3 v) const [inline]

Definition at line 266 of file vecmath.h.

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

                                                        {
                return Vector3( y * v.z - z * v.y,
                                z * v.x - x * v.z,
                                x * v.y - y * v.x );
            }
void EMAN::Vector3::print ( ) const [inline]

Definition at line 297 of file vecmath.h.

References x, y, and z.

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

Member Data Documentation

double EMAN::Vector3::x [private]
double EMAN::Vector3::y [private]
double EMAN::Vector3::z [private]

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