1. Even a vector dot multiply
Two vector points by
static double Dot (const double A[3],const Double b[3]) {return
(A[0]*b[0] + a[1]*b[1] + a[2]*b[2);
}
2. Two vector x multiplication
Vector x by
void Crossvector (const double A[3],const double b[3],double normal[3]) {
normal[0] = a[1] * b[2]-a[2] * b[ 1];
NORMAL[1] = a[2] * b[0]-a[0] * b[2];
NORMAL[2] = a[0] * b[1]-a[1] * b[0];
3. Multiply a value by a vector
Product
static void Multiplyvector (double a[3],double scalar) for a vector {for
(unsigned int i=0; i<3; i++) {
a[ I] *= scalar;
}
4.a vector orthogonal projection to B
A vector orthogonal projection to B
-bool Vectorprojection (const double A[3],const double b[3],double a1[3]) {
double bsq = Dot (b,b);
Determine whether B is 0
if (0 = bsq) {
a1[0] = 0;
A1[1] = 0;
A1[2] = 0;
return false;
}
float ratio = Dot (a,b)/bsq;
for (unsigned int i=0; i<3; i++) {
a1[i] = B[i];
}
Multiplyvector (a1,ratio);
return true;
}
A detailed interpretation of https://www.cnblogs.com/graphics/archive/2010/08/03/1791626.html by vector projection