17#define _USE_MATH_DEFINES
27 std::complex<double>
tan(std::complex<double> z);
29 inline std::complex<double>
operator + (std::complex<double> x,
int y) {
return x + (double)y; }
30 inline std::complex<double>
operator + (
int y, std::complex<double> x) {
return (
double)y + x; }
31 inline std::complex<double>
operator - (std::complex<double> x,
int y) {
return x - (double)y; }
32 inline std::complex<double>
operator - (
int y, std::complex<double> x) {
return (
double)y - x; }
34 inline std::complex<double>
operator * (std::complex<double> x,
int y) {
return x * (double)y; }
35 inline std::complex<double>
operator * (
int y, std::complex<double> x) {
return (
double)y * x; }
36 inline std::complex<double>
operator / (std::complex<double> x,
int y) {
return x / (double)y; }
37 inline std::complex<double>
operator / (
int y, std::complex<double> x) {
return (
double)y / x; }
39 inline std::complex<double>
operator + (std::complex<double> x,
long long int y) {
return x + (double)y; }
40 inline std::complex<double>
operator + (
long long int y, std::complex<double> x) {
return (
double)y + x; }
41 inline std::complex<double>
operator - (std::complex<double> x,
long long int y) {
return x - (double)y; }
42 inline std::complex<double>
operator - (
long long int y, std::complex<double> x) {
return (
double)y - x; }
44 inline std::complex<double>
operator * (std::complex<double> x,
long long int y) {
return x * (double)y; }
45 inline std::complex<double>
operator * (
long long int y, std::complex<double> x) {
return (
double)y * x; }
46 inline std::complex<double>
operator / (std::complex<double> x,
long long int y) {
return x / (double)y; }
47 inline std::complex<double>
operator / (
long long int y, std::complex<double> x) {
return (
double)y / x; }
63 for (
int i = 0; i < 3; i++)
64 os.write((
char*)&
data[i], (
char)
sizeof(
data[i]));
70 for (
int i = 0; i < 3; i++)
72 is.read((
char*)&
data[i], (
char)
sizeof(
data[i]));
101 for (
int i = 0; i < 3; i++)
125 for (
int i = 0; i < 3; i++)
184 for (
int i = 0; i < 3; i++)
193 for (
int i = 0; i < 3; i++)
208 for (
int i = 0; i < 3; i++)
218 if (
this == &r)
return *
this;
219 for (
int i = 0; i < 3; i++)
227 for (
int i = 0; i < 3; i++)
251 for (
int i = 0; i < 3; i++)
259 for (
int i = 0; i < 3; i++)
267 for (
int i = 0; i < 3; i++)
275 for (
int i = 0; i < 3; i++)
283 return ((A[0] == B[0]) && (A[1] == B[1]) && (A[2] == B[2]));
288 return !((A[0] == B[0]) && (A[1] == B[1]) && (A[2] == B[2]));
297 for (
int i = 0; i < 3; i++)
312 for (
int i = 0; i < 3; i++)
327 for (
int i = 0; i < 3; i++)
343 for (
int i = 0; i < 3; i++)
396 y[2]=atan2(x[1],x[0]);
397 if(y[2]<0) y[2]+=2.0 * M_PI;
401 y[1]=acos (x[2]/y[0]);
450 Erg[0] = P[0] * sin(P[1]) * cos(P[2]);
451 Erg[1] = P[0] * sin(P[1]) * sin(P[2]);
452 Erg[2] = P[0] * cos(P[1]);
478 double abs2(std::complex<double> x);
554 const Vector<std::complex<double> >& b);
587 return Vector<double>((
int)std::ceil(r[0]), (
int)std::ceil(r[1]), (
int)std::ceil(r[2]));
592 return Vector<int>((
int)std::ceil(r[0]), (
int)std::ceil(r[1]), (
int)std::ceil(r[2]));
598 double y = (x > 0) ? 1.0 : 0.0 + (x < 0) ? -1.0 : 0.0;
646 std::complex<double>
asin(std::complex<double> z);
647 std::complex<double>
tan(std::complex<double> z);
652#define ex Vector<double> (1.0,0.0,0.0)
653#define ey Vector<double> (0.0,1.0,0.0)
654#define ez Vector<double> (0.0,0.0,1.0)
655#define dzero Vector<double> (0.0,0.0,0.0)
658#define czero Vector<std::complex<double> > (0.0,0.0,0.0)
659#define cone Vector<std::complex<double> > (1.0,1.0,1.0)
693 std::complex<double>
asin(std::complex<double> z);
694 std::complex<double>
tan(std::complex<double> z);
719 const std::complex<double>
I = std::complex<double>(0.0, 1.0);
Template class for threedimensional vectors.
Vector & operator+=(const Vector &r)
Addition operator.
bool operator==(const Vector &r)
Comparison operators: two vectors are equal if their components are (exactly) the same.
friend T operator*(const Vector &a, const Vector &b)
friend Vector emult(const Vector &r1, const Vector &r2)
Component-wise multiplication of two vectors.
Vector & operator=(const Vector &r)
Assignment operator.
Vector & operator*=(T r)
Multiplication with scalar.
friend Vector ediv(T s, const Vector &r)
Component-wise division, scalar (s) by vector (r)
Vector & operator-=(const Vector &r)
Subtraction operator.
friend Vector operator+(const Vector &r1, const Vector &r2)
Addition of two vectors.
friend Vector sqrt(const Vector &r)
calculates the square root of a vector: result: sqrt((x,y,z))
Vector(T x, T y, T z)
Constructor with the three components as parameters.
void binRead(std::ifstream &is)
T & operator[](int i)
Bracket operator, gives access to the i-th component of the vector (as for a usual array).
void binWrite(std::ofstream &os)
Vector()
Standard constructor (all components are initialized with 0)
Vector & operator/=(T r)
Division by scalar.
bool operator!=(const Vector &r)
Inequality operator: Two vectors are inequal if at least one component is not equal.
friend Vector operator%(const Vector &r1, const Vector &r2)
cross product between two vectors.
friend Vector ediv(const Vector &r1, const Vector &r2)
Component-wise division of two vectors.
friend Vector exp(const Vector &r)
exponential function of a vector (x,y,z), defined by exp((x,y,z))
friend Vector operator/(const Vector &r, T x)
Division of a vector by a scalar.
double abs(std::complex< double > x)
absolute value of the complex valued variable x
const Vector< double > one
double valued vector with all components set to 1
Vector< double > etheta(double theta, double phi)
returns a normalized vector in theta-direction on a unit sphere with spherical coordinates /p theta a...
Vector< int > ifloor(const Vector< double > &r)
rounding up, component-by-component rounding
Vector< double > emult(const Vector< double > &r1, const Vector< int > &r2)
Vector< std::complex< double > > operator%(const Vector< std::complex< double > > &a, const Vector< double > &b)
Vector< double > ceil(const Vector< double > &r)
void rotate(Vector< double > &r, double phi)
Vector< std::complex< double > > norm(const Vector< std::complex< double > > &r)
std::ostream & operator<<(std::ostream &is, const Vector< std::complex< double > > &r)
std::complex< double > ihoch(int l)
void sphereunitv(Vector< double > &P, Vector< double > &er, Vector< double > ðeta, Vector< double > &ephi)
std::complex< double > asin(std::complex< double > z)
Vector< int > iceil(const Vector< double > &r)
double abs2(const Vector< double > &r)
Calculates the squared absolute value of double vector.
Vector< std::complex< double > > grad2d(double(*f(Vector< std::complex< double > >)), Vector< std::complex< double > > x, double dx)
calculates the gradient of a given function at a certain position
Vector< double > er(double theta, double phi)
returns a normalized vector in r-direction on a unit sphere with spherical coordinates /p theta and /...
Vector< std::complex< double > > vdc(const Vector< double > &r)
Vector< double > imag(Vector< std::complex< double > > r)
returns a vector with the imaginary parts of the components of the complex vector r
void getKSystem(const Vector< double > &n, const Vector< double > &k, Vector< double > &e1, Vector< double > &e2, Vector< double > &e3)
Calculates the three direction vectors of a coordinate system formed by the surface normal n and the ...
Vector< std::complex< double > > convd2c(const Vector< double > &r)
Vector< double > emax(Vector< double > &P1, Vector< double > &P2)
Matrix< std::complex< double > > operator-(const Matrix< double > &, const Matrix< std::complex< double > > &)
std::istream & operator>>(std::istream &is, Vector< std::complex< double > > &r)
input operator, reads complex vector from file
double arctan(double y, double x)
Matrix< std::complex< double > > operator/(const Matrix< double > &, const std::complex< double > &)
Vector< double > floor(const Vector< double > &r)
rounding up, Component-by-component
Vector< double > real(Vector< std::complex< double > > r)
returns a vector with the real parts of the components of the complex vector r
Matrix< std::complex< double > > operator*(const Matrix< double > &, const Matrix< std::complex< double > > &)
Vector< std::complex< double > > * conv2vector(int num, double *r)
This function converts a list of doubles into a list of complex vectors.
Matrix< std::complex< double > > operator+(const Matrix< double > &, const Matrix< std::complex< double > > &)
Vector< double > arg(Vector< std::complex< double > > &r)
Vector< std::complex< double > > conj(const Vector< std::complex< double > > &r)
Conjugate complex of the vector r.
Vector< std::complex< double > > makeReal(const Vector< std::complex< double > > &r)
double * conv2double(int numV, Vector< std::complex< double > > *r)
This function returns an array with all components of the Vector-array r.
double sViereck(Vector< double >, Vector< double >, Vector< double >, Vector< double >)
std::complex< double > tan(std::complex< double > z)
Vector< T > sphere2cart(const Vector< T > &P)
Transforms vector from spherical coordinates into cartesian coordinates.
Vector< double > ephi(double theta, double phi)
returns a normalized vector in phi-direction on a unit sphere with spherical coordinates /p theta and...
double sDreieck(Vector< double >, Vector< double >, Vector< double >)
bool isnan(Vector< std::complex< double > > v)
returns true if one of the components of v is NaN
Vector< T > cart2sphere(const Vector< T > &x)
Transformation from cartesian coordinates to spherical coordinates.
char * toString(char *S, Vector< double > P)
Converts a double vector into a string.
Vector< double > nanV(const char *tagp)
This class is used for the iray class. This class is intended for internal use only....