AcouSTO  version 2.0

◆ vec_rotate2()

vec_rotate2 ( struct vector x1,
struct vector nu,
struct vector x0,
DOUBLE  theta 
)

Rotates a point of coordinates x1 of the angle theta around the axis defined by the vector nu (not need to be unitary), applied at point x0. The original vector is overwritten.

Parameters
[in,out]x1
[in]x0
[in]nu
[in]theta
278  {
279 
280  DOUBLE x,y,z;
281  DOUBLE a,b,c;
282  DOUBLE u,v,w;
283  struct vector vtmp;
284 
285  x = x1->x;
286  y = x1->y;
287  z = x1->z;
288 
289  a = x0->x;
290  b = x0->y;
291  c = x0->z;
292 
293  u = (nu->x)/vec_mod(*nu);
294  v = (nu->y)/vec_mod(*nu);
295  w = (nu->z)/vec_mod(*nu);
296 
297  vtmp.x = (a*(v*v + w*w) - u*(b*v + c*w - u*x - v*y - w*z))*(1.0 - cos(theta)) + x*cos(theta) + (-c*v + b*w - w*y + v*z)*sin(theta);
298  vtmp.y = (b*(u*u + w*w) - v*(a*u + c*w - u*x - v*y - w*z))*(1.0 - cos(theta)) + y*cos(theta) + (+c*u - a*w + w*x - u*z)*sin(theta);
299  vtmp.z = (c*(u*u + v*v) - w*(a*u + b*v - u*x - v*y - w*z))*(1.0 - cos(theta)) + z*cos(theta) + (-b*u + a*v - v*x + u*y)*sin(theta);
300 
301  x1->x = vtmp.x;
302  x1->y = vtmp.y;
303  x1->z = vtmp.z;
304 }
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
DOUBLE vec_mod(struct vector v)
Definition: math.c:121
DOUBLE y
Definition: structs.h:33