Find Scalar for sum of Vector3 to be in certain direction

Hello,
I am working on a kite simulator, I struggle while working on my sum forces.

Vector 3 totalForce = lift + drag + weight + lineTension

lineTension is a Vector3 which we know the direction but need to find his coefficient K which should lead to a totalForce orthogonal to the lineTension.

Hope my little drawing will be easier to understand than my explanation :slight_smile:

I drawed the simplest position where lineTension is (-1,0,0) but kite will rise (eventually)/

You can use vector projection via the dot product to figure out the scalar between two vectors to find an orthogonal axis:

// First, find the total force without line tension
Vector3 totalForce = lift + drag + weight;

// The, take the dot product between the above force and the direction of line tension
// Make sure 'lineTension' is normalized (if it is already normalized, no need to do it again here)
lineTension.Normalize ();
float k = Vector3.Dot (totalForce, lineTension);

// Finally, subtract line tension from the total force scaled by it's dot project to project it onto an orthogonal axis
totalForce -= lineTension * k;