• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] Length of a vector in a given direction

Status
Not open for further replies.
Alright, i am not sure how to describe this problem to you, but let's give it a go:

Background:

I have a system in my map, dealing wth physics. It works by applying the different forces impacting on an object on a velocity vector, and then applying the velocity vector onto the units position.

Examples of forces impacting on an object are:

*gravity
*thrust
*air/ground friction

Thrust is being applied by multiplying the units rotation vector with a scalar value of the objects acceleration, and then adding that to the velocity.
Rotation is represented by a vector with the length of 1 (a unit vector) pointing in the direction that the unit is facing.

I am trying to apply the force of lift onto airplanes using a certain formula. The formula produces a scalar lift value that is meant to be applied in the relative upwards direction of the object.

This formula is depending on the velocity of the object in it's forwards direction.

Now, my problem is this:

If i use the length of the velocity vector as the speed, i get the speed in the direction the object is moving, not the direction it is facing. The airplane might aswell be falling straight down, and that should not be producing lift!

On the other hand, if i use the scalar value of the planes acceleration, i only get the speed produced by the engine thrust, which is only one of the factors affecting the velocity of the object. What if the airplane is pointing straigt up, but the thrust is weaker than the force of gravity, so that the plane is actually moving downwards?

Is there any way i can find out, how strong the velocity is in the direction the unit is facing?

EDIT: i think i actually imagined this a bit more complicated than it is - if the rotation vector is a unit vector, it should just be enough to multiply the velocity by the rotation, right?
I will just go with this. Let me know if i am wrong.
 
Status
Not open for further replies.
Top