AcouSTO  version 2.0

◆ vec_rotate()

void vec_rotate ( struct vector v,
DOUBLE  phi,
DOUBLE  theta,
DOUBLE  psi 
)

Rotates a vector with three angles. The original vector is overwritten.

Parameters
[in,out]v
[in]phi
[in]theta
[in]psi
238  {
239 
240  DOUBLE m11,m12,m13;
241  DOUBLE m21,m22,m23;
242  DOUBLE m31,m32,m33;
243  struct vector vtmp;
244 
245  m11 = COS(theta)*COS(psi);
246  m12 = -COS(phi)*SIN(psi) + SIN(phi)*SIN(theta)*COS(psi);
247  m13 = SIN(phi)*SIN(psi) + COS(phi)* SIN(theta)*COS(psi);
248 
249  m21 = COS(theta)*SIN(psi);
250  m22 = COS(phi)*COS(psi) + SIN(phi)*SIN(theta)*SIN(psi);
251  m23 = -SIN(phi)*COS(psi) + COS(phi)*SIN(theta)*SIN(psi);
252 
253  m31 = -SIN(theta);
254  m32 = SIN(phi) * COS(theta);
255  m33 = COS(phi) * COS(theta);
256 
257  vtmp.x = m11* v->x + m12*v->y + m13*v->z;
258  vtmp.y = m21* v->x + m22*v->y + m23*v->z;
259  vtmp.z = m31* v->x + m32*v->y + m33*v->z;
260 
261  v->x = vtmp.x;
262  v->y = vtmp.y;
263  v->z = vtmp.z;
264 }
#define COS(x)
Definition: functions.h:53
vector struct to hold triplets.
Definition: structs.h:29
DOUBLE z
Definition: structs.h:35
double DOUBLE
Definition: types.h:44
DOUBLE x
Definition: structs.h:31
#define SIN(x)
Definition: functions.h:52
DOUBLE y
Definition: structs.h:33