XHLin XHLin - 14 days ago 4
C++ Question

How to simulate the left-hand rule?

enter image description here

I use a struct to represent the direction like this:

struct POINT{
double x;
double y;
double z;
}


Given the
B(Bx,By,Bz)
and
I(Ix,Iy,Iz)
. How to determine the F?

Answer

Your question is actually what is the algorithm for a vector cross-product.

POINT F;
F.x = (B.y * I.z) - (B.z * I.y);
F.y = (B.z * I.x) - (B.x * I.z);
F.z = (B.x * I.y) - (B.y * I.x);