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

#include <vecmath.h>

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

Constructor & Destructor Documentation

◆ Vector4() [1/3]

EMAN::Vector4::Vector4 ( )
inline

Definition at line 590 of file vecmath.h.

590: x(0), y(0), z(0), w(0) {}
double w
Definition: vecmath.h:677
double z
Definition: vecmath.h:677
double y
Definition: vecmath.h:677
double x
Definition: vecmath.h:677

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

◆ Vector4() [2/3]

EMAN::Vector4::Vector4 ( const Vector4 v)
inline

Definition at line 591 of file vecmath.h.

591: x(v[0]), y(v[1]), z(v[2]), w(v[3]) {}

◆ Vector4() [3/3]

EMAN::Vector4::Vector4 ( double  _x,
double  _y,
double  _z,
double  _w 
)
inline

Definition at line 592 of file vecmath.h.

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

Member Function Documentation

◆ approxEqual()

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

Definition at line 668 of file vecmath.h.

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

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

◆ length()

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

Definition at line 647 of file vecmath.h.

647 {
648 return (double) sqrt(x * x + y * y + z * z + w * w);
649 }
EMData * sqrt() const
return square root of current image

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

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

◆ lengthSquared()

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

Definition at line 651 of file vecmath.h.

651 {
652 return x * x + y * y + z * z + w * w;
653 }

References w, x, y, and z.

◆ normalize()

void EMAN::Vector4::normalize ( )
inline

Definition at line 655 of file vecmath.h.

655 {
656 double s = 1.0 / length();
657 x *= s; y *= s; z *= s; w *= s;
658 }
double length() const
Definition: vecmath.h:647

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

◆ operator!=()

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

Definition at line 664 of file vecmath.h.

664 {
665 return x != v.x || y != v.y || z != v.z || w != v.w;
666 }

References w, x, y, and z.

◆ operator*() [1/2]

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

Definition at line 638 of file vecmath.h.

638 {
639 return Vector4( x * s, y * s, z * s, w * s );
640 }

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

◆ operator*() [2/2]

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

Definition at line 643 of file vecmath.h.

643 {
644 return x * v.x + y * v.y + z * v.z + w * v.w;
645 }

References w, x, y, and z.

◆ operator*=()

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

Definition at line 612 of file vecmath.h.

612 {
613 x *= s; y *= s; z *= s; w *= s;
614 return *this;
615 }

References w, x, y, and z.

◆ operator+() [1/2]

Vector4 EMAN::Vector4::operator+ ( )
inline

Definition at line 621 of file vecmath.h.

621 {
622 return *this;
623 }

◆ operator+() [2/2]

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

Definition at line 625 of file vecmath.h.

625 {
626 return Vector4( x + v.x, y + v.y, z + v.z, w + v.w );
627 }

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

◆ operator+=()

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

Definition at line 602 of file vecmath.h.

602 {
603 x += a[0]; y += a[1]; z += a[2]; w += a[3];
604 return *this;
605 }

References w, x, y, and z.

◆ operator-() [1/2]

Vector4 EMAN::Vector4::operator- ( )
inline

Definition at line 617 of file vecmath.h.

617 {
618 return Vector4(-x, -y, -z, -w);
619 }

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

◆ operator-() [2/2]

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

Definition at line 629 of file vecmath.h.

629 {
630 return Vector4( x - v.x, y - v.y, z - v.z, w - v.w );
631 }

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

◆ operator-=()

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

Definition at line 607 of file vecmath.h.

607 {
608 x -= a[0]; y -= a[1]; z -= a[2]; w -= a[3];
609 return *this;
610 }

References w, x, y, and z.

◆ operator/()

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

Definition at line 633 of file vecmath.h.

633 {
634 Assert( s > 0.0 );
635 return Vector4( x / s, y / s, z / s, w / s );
636 }
#define Assert(s)
Define Assert() function that is effective only when -DDEBUG is used.
Definition: emassert.h:42

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

◆ operator=()

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

Definition at line 594 of file vecmath.h.

594 {
595 x = a[0]; y = a[1]; z = a[2]; w = a[3];
596 return *this;
597 }

References w, x, y, and z.

◆ operator==()

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

Definition at line 660 of file vecmath.h.

660 {
661 return x == v.x && y == v.y && z == v.z && w == v.w;
662 }

References w, x, y, and z.

◆ operator[]() [1/2]

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

Definition at line 600 of file vecmath.h.

600{ return ((double *) this)[n]; }

◆ operator[]() [2/2]

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

Definition at line 599 of file vecmath.h.

599{ return ((double *) this)[n]; }

◆ print()

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

Definition at line 672 of file vecmath.h.

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

References w, x, y, and z.

Member Data Documentation

◆ w

double EMAN::Vector4::w
private

◆ x

double EMAN::Vector4::x
private

◆ y

double EMAN::Vector4::y
private

◆ z

double EMAN::Vector4::z
private

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