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

#include <vecmath.h>

List of all members.

Public Member Functions

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

Private Attributes

double x
double y
double z
double w

Detailed Description

Definition at line 592 of file vecmath.h.


Constructor & Destructor Documentation

EMAN::Vector4::Vector4 ( ) [inline]

Definition at line 594 of file vecmath.h.

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

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

Definition at line 595 of file vecmath.h.

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

Definition at line 596 of file vecmath.h.

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

Member Function Documentation

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

Definition at line 672 of file vecmath.h.

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

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

Definition at line 651 of file vecmath.h.

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

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

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

Definition at line 655 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 659 of file vecmath.h.

References length(), w, x, y, and z.

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

Definition at line 668 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 642 of file vecmath.h.

References Vector4(), w, x, y, and z.

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

Definition at line 647 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 616 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 629 of file vecmath.h.

References Vector4(), w, x, y, and z.

                                                        {
                return Vector4( x + v.x, y + v.y, z + v.z, w + v.w );
            }
Vector4 EMAN::Vector4::operator+ ( ) [inline]

Definition at line 625 of file vecmath.h.

                                {
                return *this;
            }
Vector4& EMAN::Vector4::operator+= ( const Vector4 a) [inline]

Definition at line 606 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 633 of file vecmath.h.

References Vector4(), w, x, y, and z.

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

Definition at line 621 of file vecmath.h.

References Vector4(), w, x, y, and z.

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

Definition at line 611 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 637 of file vecmath.h.

References Assert, Vector4(), w, x, y, and z.

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

Definition at line 598 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 664 of file vecmath.h.

References w, x, y, and z.

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

Definition at line 604 of file vecmath.h.

{ return ((double *) this)[n]; }
const double& EMAN::Vector4::operator[] ( int  n) const [inline]

Definition at line 603 of file vecmath.h.

{ return ((double *) this)[n]; }
void EMAN::Vector4::print ( ) const [inline]

Definition at line 676 of file vecmath.h.

References w, x, y, and z.

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

Member Data Documentation

double EMAN::Vector4::w [private]
double EMAN::Vector4::x [private]
double EMAN::Vector4::y [private]
double EMAN::Vector4::z [private]

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