Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Vector.h
Go to the documentation of this file.
1/*
2(c) 2005, Supratik Mukhopadhayay, Nayana Majumdar
3*/
4#ifndef _Vector_H_
5#define _Vector_H_
6
7#ifdef DEFINE_VGLOBAL
8#define VGLOBAL
9#else
10#define VGLOBAL extern
11#endif
12
13#define global2local 1
14#define local2global -1
15
16#ifdef __cplusplus
17namespace neBEM {
18#endif
19
20// three coordinates
21typedef struct {
22 double X;
23 double Y;
24 double Z;
25} Point3D;
26
27// three vector components
28typedef struct {
29 double X;
30 double Y;
31 double Z;
32} Vector3D;
33
34// direction cosine
35typedef struct {
40
41// Creates a 3D point {x,y,z} - note sequence
42VGLOBAL Point3D CreatePoint3D(double x, double y, double z);
43
44// Get the distance between two 3D points
46
47// Create a 3D distance vector from point a to point b - note sequence
49
50// Compute magnitude of a 3D vector
52
53// Create the unit vector of vector a
55
56// prints out co-ordinates of a 3D point
58
59// prints out components of a 3D vector
61
62// prints out components of 3D direction cosines
64
65// Rotates a vector
66VGLOBAL void VectorRotate_Rect3D(double Xin, double Yin, double Zin,
67 double RotX, double RotY, double RotZ,
68 int Opt, // 1 forward, -1 backward
69 double *Xout, double *Yout, double *Zout);
70
71// Transforms a point
72VGLOBAL void CoordRotate_Rect3D(double Xin, double Yin, double Zin, double RotX,
73 double RotY, double RotZ,
74 int Opt, // 1 forward, -1 backward
75 double *Xout, double *Yout, double *Zout);
76
77// Carries out a vector dot-product
79
80// Carries out a vector cross-product - be sure that the order is correct!
82
83// Translates a point to a new origin specified in terms of the existing system
84VGLOBAL Point3D TranslatePoint3D(Point3D *A, Point3D *Origin, int Sense);
85
86// Position of a point in a coord system with direction cosines specified
87// in terms of the existing system
88VGLOBAL Point3D RotatePoint3D(Point3D *A, DirnCosn3D *Origin, int Sense);
89
90// Vector in a coord system with direction cosines specified
91// in terms of the existing system
92VGLOBAL Vector3D RotateVector3D(Vector3D *A, DirnCosn3D *Origin, int Sense);
93
94// Transform point: Get the new coordinates of a point described in the
95// original// coordinate system. The new system of coordinates
96// is also
97// described in terms of the original coordiate system, the
98// origin being NewOrigin and new direction cosines being
99// termed as NewDirns.
100// Translate-Rotate sequence
101// Inputs: point in the original coordinate system, origin of the new system
102// w.r.t the original coord system, direction cosines of the new
103// system w.r.t the original coord system
104VGLOBAL Point3D TransformPoint3D(Point3D *initial, Point3D *NewOrigin,
105 DirnCosn3D *NewDirns);
106
107// Reflect a point using a mirror passing through the origin
109
110// Product of two matrices
111VGLOBAL double **MatrixProduct(int NbRows1, int NbCols1, double **Matrix1,
112 int NbRows2, int NbCols2, double **Matrix2);
113
114#ifdef __cplusplus
115} // namespace
116#endif
117
118#endif
Point3D ReflectPoint3DByMirrorAtOrigin(Point3D *p1, Vector3D *n)
Definition: Vector.c:467
Vector3D CreateDistanceVector3D(Point3D *a, Point3D *b)
Definition: Vector.c:198
void VectorRotate_Rect3D(double Xin, double Yin, double Zin, double RotX, double RotY, double RotZ, int Opt, double *Xout, double *Yout, double *Zout)
Definition: Vector.c:17
Point3D RotatePoint3D(Point3D *A, DirnCosn3D *DC, int Sense)
Definition: Vector.c:339
void CoordRotate_Rect3D(double Xin, double Yin, double Zin, double RotX, double RotY, double RotZ, int Opt, double *Xout, double *Yout, double *Zout)
Definition: Vector.c:100
Point3D TranslatePoint3D(Point3D *A, Point3D *Origin, int Sense)
Definition: Vector.c:285
double MagVector3D(Vector3D *A)
Definition: Vector.c:209
Vector3D RotateVector3D(Vector3D *A, DirnCosn3D *DC, int Sense)
Definition: Vector.c:397
double Vector3DDotProduct(Vector3D *A, Vector3D *B)
Definition: Vector.c:218
Point3D TransformPoint3D(Point3D *initial, Point3D *NewOrigin, DirnCosn3D *NewDirns)
Definition: Vector.c:455
int PrintVector3D(Vector3D A)
Definition: Vector.c:263
double GetDistancePoint3D(Point3D *a, Point3D *b)
Definition: Vector.c:192
Vector3D UnitVector3D(Vector3D *v)
Definition: Vector.c:227
Vector3D Vector3DCrossProduct(Vector3D *A, Vector3D *B)
Definition: Vector.c:246
int PrintDirnCosn3D(DirnCosn3D A)
Definition: Vector.c:269
Point3D CreatePoint3D(double x, double y, double z)
Definition: Vector.c:182
int PrintPoint3D(Point3D A)
Definition: Vector.c:257
#define VGLOBAL
Definition: Vector.h:10
VGLOBAL double ** MatrixProduct(int NbRows1, int NbCols1, double **Matrix1, int NbRows2, int NbCols2, double **Matrix2)
Vector3D ZUnit
Definition: Vector.h:38
Vector3D YUnit
Definition: Vector.h:37
Vector3D XUnit
Definition: Vector.h:36
Definition: Vector.h:21
double X
Definition: Vector.h:22
double Z
Definition: Vector.h:24
double Y
Definition: Vector.h:23
double Z
Definition: Vector.h:31
double Y
Definition: Vector.h:30
double X
Definition: Vector.h:29