Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads

Homogenous vector for three dimensional space. More...

#include <vec4d.hpp>

Public Member Functions

 Vec4D (double x)
 
 Vec4D (double x, double y)
 
 Vec4D (double x, double y, double z)
 
 Vec4D (double x, double y, double z, double w)
 
 Vec4D (const class Vec3D &vec)
 Convert 3D vector to 4D vector. More...
 
 Vec4D (std::istream &s)
 
double & operator[] (int i)
 
const double & operator[] (int i) const
 
double & operator() (int i)
 
const double & operator() (int i) const
 
Vec4D operator+ (const Vec4D &vec) const
 Addition. More...
 
Vec4D operator- (const Vec4D &vec) const
 Difference. More...
 
Vec4Doperator+= (const Vec4D &vec)
 Accumulation. More...
 
double operator* (const Vec4D &vec) const
 Dot product. More...
 
Vec4D operator* (double x) const
 Vector scaling. More...
 
Vec4Doperator*= (double x)
 Vector scaling. More...
 
Vec4Doperator/= (double x)
 Vector scaling with divisor. More...
 
bool operator!= (const Vec4D &x)
 Inequality test. More...
 
bool operator== (const Vec4D &x)
 Equality test. More...
 
Vec4Doperator= (const Vec4D &x)
 Assignment. More...
 
void homogenize ()
 Homogenize vector. More...
 
void normalize ()
 Normalize vector. More...
 
double norm2 () const
 Returns 2-norm of vector. More...
 
double ssqr () const
 Returns square of 2-norm of vector. More...
 
void save (std::ostream &s) const
 

Friends

Vec4D cross (const Vec4D &vec1, const Vec4D &vec2)
 Cross product. More...
 
double norm2 (const Vec4D &vec)
 Second norm of vector. More...
 
Vec4D operator* (double x, const Vec4D &vec)
 Vector scaling. More...
 
std::ostream & operator<< (std::ostream &os, const Vec4D &vec)
 Outputting to stream. More...
 

Detailed Description

Homogenous vector for three dimensional space.

Homogenous space has 4-vectors (x,y,z,w).

Most operations assume the arguments are either vectors (w=0) or points (w=1). These are only checked where the algorithm is dependent on this information. Otherwise the fourth coordinate (w) is assumed what the algorithm is designed for. User is responsible for calling legal operations for corrent type of vectors.

Constructor & Destructor Documentation

◆ Vec4D()

Vec4D::Vec4D ( const class Vec3D vec)

Convert 3D vector to 4D vector.

Makes 3D vector a point.

Member Function Documentation

◆ homogenize()

void Vec4D::homogenize ( )
inline

Homogenize vector.

Homogenize vector by dividing all components of vector with w. Not valid for w=0.

◆ norm2()

double Vec4D::norm2 ( void  ) const
inline

Returns 2-norm of vector.

$ ||x||_2 = \sqrt{ \Sigma_{i=1}^3 x_i^2 } $

◆ normalize()

void Vec4D::normalize ( void  )
inline

Normalize vector.

Only valid for vector. Output is guaranteed to be a vector.

◆ operator!=()

bool Vec4D::operator!= ( const Vec4D x)
inline

Inequality test.

Also tests w.

◆ operator*() [1/2]

double Vec4D::operator* ( const Vec4D vec) const
inline

Dot product.

Valid for vectors only.

◆ operator*() [2/2]

Vec4D Vec4D::operator* ( double  x) const
inline

Vector scaling.

Valid for points and vectors. Scaling does not affect w.

◆ operator*=()

Vec4D& Vec4D::operator*= ( double  x)
inline

Vector scaling.

Valid for points and vectors. Scaling does not affect w.

◆ operator+()

Vec4D Vec4D::operator+ ( const Vec4D vec) const
inline

Addition.

Only valid for point+vector=point or vector+vector=vector. Output is of the correct type.

◆ operator+=()

Vec4D& Vec4D::operator+= ( const Vec4D vec)
inline

Accumulation.

Only valid for point += vector or vector += vector. Output type does not change.

◆ operator-()

Vec4D Vec4D::operator- ( const Vec4D vec) const
inline

Difference.

Only valid for vector-vector=vector, point-vector=point or point-point=vector. Output is of the correct type.

◆ operator/=()

Vec4D& Vec4D::operator/= ( double  x)
inline

Vector scaling with divisor.

Valid for points and vectors. Scaling does not affect w.

◆ operator=()

Vec4D& Vec4D::operator= ( const Vec4D x)
inline

Assignment.

◆ operator==()

bool Vec4D::operator== ( const Vec4D x)
inline

Equality test.

Also tests w.

◆ ssqr()

double Vec4D::ssqr ( void  ) const
inline

Returns square of 2-norm of vector.

$ (||x||_2)^2 = \Sigma_{i=1}^3 x_i^2 $

Friends And Related Function Documentation

◆ cross

Vec4D cross ( const Vec4D vec1,
const Vec4D vec2 
)
friend

Cross product.

Only valid for vectors. Output is guaranteed to be a vector.

◆ norm2

double norm2 ( const Vec4D vec)
friend

Second norm of vector.

◆ operator*

Vec4D operator* ( double  x,
const Vec4D vec 
)
friend

Vector scaling.

Does not affect w.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Vec4D vec 
)
friend

Outputting to stream.


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


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.