Rotates v1 through an angle (in radians) within the plane defined by v1/v2, returns the rotated vector in n.
572 double cos_a = cos(angle);
573 double sin_a = sin(angle);
574 double uxuy, uyuz, uxuz;
575 double ux2, uy2, uz2;
576 double rxx, rxy, rxz, ryx, ryy, ryz, rzx, rzy, rzz;
589 rxx = cos_a + ux2 * (1 - cos_a);
590 rxy = uxuy * (1 - cos_a) - u.
z * sin_a;
591 rxz = uxuz * (1 - cos_a) + u.
y * sin_a;
593 ryx = uxuy * (1 - cos_a) + u.
z * sin_a;
594 ryy = cos_a + uy2 * (1 - cos_a);
595 ryz = uyuz * (1 - cos_a) - u.
x * sin_a;
597 rzx = uxuz * (1 - cos_a) - u.
y * sin_a;
598 rzy = uyuz * (1 - cos_a) + u.
x * sin_a;
599 rzz = cos_a + uz2 * (1 - cos_a);
601 n->
x = rxx * v1->
x + rxy * v1->
y + rxz * v1->
z;
602 n->
y = ryx * v1->
x + ryy * v1->
y + ryz * v1->
z;
603 n->
z = rzx * v1->
x + rzy * v1->
y + rzz * v1->
z;
void normalize(POINT3D *p)
Normalize to a unit vector.
void unit_normal(const POINT3D *P1, const POINT3D *P2, POINT3D *normal)
Calculates the unit normal to two vectors, trying to avoid problems with over-narrow or over-wide cas...