HIPO  4.3.0
High Performance Output data format for experimental physics
fizika::vector3 Class Reference

Three-dimensional Cartesian vector. More...

#include <fizika.h>

Public Member Functions

 vector3 ()
 Default constructor (uninitialized components). More...
 
 vector3 (double x, double y, double z)
 Construct from Cartesian components. More...
 
 ~vector3 ()
 
void setXYZ (double x, double y, double z)
 Set the Cartesian components. More...
 
void setMagThetaPhi (double mag, double theta, double phi)
 Set the vector from spherical coordinates. More...
 
double theta () const
 
double phi () const
 
double perp () const
 
double perp2 () const
 
double mag2 () const
 
double mag () const
 
double x () const
 
double y () const
 
double z () const
 
void setX (double _x)
 Set the X component. More...
 
void setY (double _y)
 Set the Y component. More...
 
void setZ (double _z)
 Set the Z component. More...
 
double angle (const vector3 &q)
 Compute the angle between this vector and another. More...
 
void rotateX (double angle)
 Rotate the vector around the X axis. More...
 
void rotateY (double angle)
 Rotate the vector around the Y axis. More...
 
void rotateZ (double angle)
 Rotate the vector around the Z axis. More...
 
vector3 unit () const
 
vector3 cross (const vector3 &vec) const
 Compute the cross product with another vector. More...
 
double dot (const vector3 &vec) const
 Compute the dot product with another vector. More...
 
void print (const char *_line="V3 ")
 Print the vector components and magnitude to stdout. More...
 
const vector3operator= (const vector3 &vec)
 Copy-assignment operator. More...
 
vector3operator+= (const vector3 &)
 Add another vector to this one in place. More...
 
vector3operator-= (const vector3 &)
 Subtract another vector from this one in place. More...
 

Detailed Description

Three-dimensional Cartesian vector.

Supports basic vector algebra (addition, subtraction, scalar multiplication), rotations around the coordinate axes, and conversions to spherical coordinates.

Definition at line 47 of file fizika.h.

Constructor & Destructor Documentation

◆ vector3() [1/2]

fizika::vector3::vector3 ( )
inline

Default constructor (uninitialized components).

Definition at line 55 of file fizika.h.

◆ vector3() [2/2]

fizika::vector3::vector3 ( double  x,
double  y,
double  z 
)
inline

Construct from Cartesian components.

Definition at line 57 of file fizika.h.

◆ ~vector3()

fizika::vector3::~vector3 ( )
inline

Definition at line 59 of file fizika.h.

Member Function Documentation

◆ angle()

double fizika::vector3::angle ( const vector3 q)
inline

Compute the angle between this vector and another.

Parameters
qThe other vector
Returns
Angle in radians

Definition at line 115 of file fizika.h.

◆ cross()

vector3 fizika::vector3::cross ( const vector3 vec) const
inline

Compute the cross product with another vector.

Parameters
vecThe other vector

Definition at line 153 of file fizika.h.

◆ dot()

double fizika::vector3::dot ( const vector3 vec) const
inline

Compute the dot product with another vector.

Parameters
vecThe other vector

Definition at line 160 of file fizika.h.

◆ mag()

double fizika::vector3::mag ( ) const
inline
Returns
Magnitude of the vector.

Definition at line 95 of file fizika.h.

◆ mag2()

double fizika::vector3::mag2 ( ) const
inline
Returns
Square of the magnitude.

Definition at line 91 of file fizika.h.

◆ operator+=()

vector3 & fizika::vector3::operator+= ( const vector3 p)
inline

Add another vector to this one in place.

Definition at line 200 of file fizika.h.

◆ operator-=()

vector3 & fizika::vector3::operator-= ( const vector3 p)
inline

Subtract another vector from this one in place.

Definition at line 203 of file fizika.h.

◆ operator=()

const vector3& fizika::vector3::operator= ( const vector3 vec)
inline

Copy-assignment operator.

Definition at line 171 of file fizika.h.

◆ perp()

double fizika::vector3::perp ( ) const
inline
Returns
Transverse component (perpendicular to Z axis).

Definition at line 83 of file fizika.h.

◆ perp2()

double fizika::vector3::perp2 ( ) const
inline
Returns
Square of the transverse component.

Definition at line 87 of file fizika.h.

◆ phi()

double fizika::vector3::phi ( ) const
inline
Returns
Azimuthal angle in radians.

Definition at line 79 of file fizika.h.

◆ print()

void fizika::vector3::print ( const char *  _line = "V3 ")
inline

Print the vector components and magnitude to stdout.

Parameters
_lineLabel prefix for the output line

Definition at line 166 of file fizika.h.

◆ rotateX()

void fizika::vector3::rotateX ( double  angle)
inline

Rotate the vector around the X axis.

Parameters
angleRotation angle in radians

Definition at line 128 of file fizika.h.

◆ rotateY()

void fizika::vector3::rotateY ( double  angle)
inline

Rotate the vector around the Y axis.

Parameters
angleRotation angle in radians

Definition at line 135 of file fizika.h.

◆ rotateZ()

void fizika::vector3::rotateZ ( double  angle)
inline

Rotate the vector around the Z axis.

Parameters
angleRotation angle in radians

Definition at line 142 of file fizika.h.

◆ setMagThetaPhi()

void fizika::vector3::setMagThetaPhi ( double  mag,
double  theta,
double  phi 
)
inline

Set the vector from spherical coordinates.

Parameters
magMagnitude
thetaPolar angle (radians)
phiAzimuthal angle (radians)

Definition at line 67 of file fizika.h.

◆ setX()

void fizika::vector3::setX ( double  _x)
inline

Set the X component.

Definition at line 106 of file fizika.h.

◆ setXYZ()

void fizika::vector3::setXYZ ( double  x,
double  y,
double  z 
)
inline

Set the Cartesian components.

Definition at line 62 of file fizika.h.

◆ setY()

void fizika::vector3::setY ( double  _y)
inline

Set the Y component.

Definition at line 108 of file fizika.h.

◆ setZ()

void fizika::vector3::setZ ( double  _z)
inline

Set the Z component.

Definition at line 110 of file fizika.h.

◆ theta()

double fizika::vector3::theta ( ) const
inline
Returns
Polar angle in radians.

Definition at line 75 of file fizika.h.

◆ unit()

vector3 fizika::vector3::unit ( ) const
Returns
A unit vector in the same direction.

◆ x()

double fizika::vector3::x ( ) const
inline
Returns
X component.

Definition at line 99 of file fizika.h.

◆ y()

double fizika::vector3::y ( ) const
inline
Returns
Y component.

Definition at line 101 of file fizika.h.

◆ z()

double fizika::vector3::z ( ) const
inline
Returns
Z component.

Definition at line 103 of file fizika.h.


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