XHLin
XHLin

Reputation: 321

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?

Upvotes: 2

Views: 444

Answers (1)

acraig5075
acraig5075

Reputation: 10756

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);

Upvotes: 6

Related Questions