This site uses strictly necessary cookies. More Information

X# Trying to find air speed of a plane, as opposed to distance traveled

I'm putting together a sort of flight sim, and I'm trying to measure the air speed of my aircraft - The speed at which air flows over the wings - in order to determine the amount of lift generated. I can measure the distance the aircraft moves between frames by comparing transform.position before and after, but this doesn't take into account things like falling straight down, or potential lateral movement. See this illustration:

The aircraft on the left is frame 1, while the aircraft on the lower right is frame 2. I can get the distance between them easily, but that's not what I want. I want to isolate just the plane (No pun intended) that frame 1's direction.forward lies on, and (I guess?) find that component's contribution to the aircraft's motion. This would be the slightly transparent hypothetical aircraft in the upper right, which I assume would be a reasonably accurate representation of air speed.

So primarily my question is: How do I do this? And a secondary question would be, is this what I should be doing in the first place?

You could jsut offset the vectors that your measure the distance of between frames so the vectors are far away from the pivot of the object. This would at least take care of lateral movement. $$anonymous$$aybe just measure the distance for one wing tip?

**Answer** by infinitesunrise
·
Apr 02, 2016 at 12:52 AM

Found an answer to this, I just needed to read more documentation. Vector3.Dot() lets you find the dot product between two vectors (1 for parallel and in alignment, 0 for perpendicular and -1 for parallel but in opposite alignment), while Vector3.Angle() lets you find the angle between two vectors in degrees, from which you can then work out the component of one vector within the other. Dot() is a bit tricky in some circumstances what with the plane moving and all, so I'm gone the Angle() route.

My code in case anyone is interested:

```
Vector3 displacementVector = transform.position - lastLocation;
float displacement = displacementVector.magnitude / Time.deltaTime;
airSpeed = ((90.0f - Vector3.Angle(displacementVector, transform.forward)) / 90.0f) * displacement;
```

I normalize it to 90 because my in-game plane is a human-powered glider, no fancy loop-the-loops or anything like that.

**Answer** by phxvyper
·
Mar 31, 2016 at 11:07 PM

**Prepare thy self, Calculus Incoming!**

Provided that there is no wind speed, such that if the plane didn't exist, there would be no wind, you can determine how much force is being applied to the wings. I don't know if this is how *consumer* flight simulations *games* do this, but this is how to do it with some level of accuracy.

I'm going to **massively** simplify the equations for Lift and air friction (as provided by NASA's documentation) due to the fact that finding a coefficient for your object is very complex and there are a lot of other equations and arithmetic involved in determining a specific coefficient for a specific object. We're going to assume that your coefficient is 1. Its up to you to change this value until the motion of the plane feels more realistic or how ever you want it to feel.

Your goal here is to determine the amount of Torque (Td) created around the wings. This, along with the force caused by jet propulsion, and the force caused by the y axis of the drag (Fdy), will produce your overall Lift.

You can determine that Fdy = Fd * cos(pi)

In the equations above, C = 1, p = air density, A = cross-sectional surface area of the wing bow, and v = velocity. Also, r is equal to the length of the bow of the wing. The bow is the section of the wing that is rotated by a rotor in order to produce all of these desired results. If you haven't seen this in action, look up some videos on plane lift.

The following equation is the final equation for determining how much torque is present .

**In Conclusion:**

Use these equations to determine how much rotation occurs. Then use the force of drag in the y-axis to determine how much lift force is caused by air friction. Finally, use the force caused by whatever source of propulsion you have to increase/decrease velocity and indirectly produce this lift effect.

P.S.

Sorry for my pretty bad handwriting, lol.

WOW! That's an immense amount of work! Actually, it's not much more work than I'm already doing. $$anonymous$$y in-game plane already has a lift coefficient (0.45, very low but it actually works out well at that number), air density (1.225 for now) and a surface area ("3"... Heh), and I've been working out it's movement via newtonian forces so of course seeing this calculus all of a sudden comes as a shock. It sounds like this would work, but I actually found a much simpler way to get the forward component of the plane's displacement, and that is by using Vector3's Dot() and Angle() methods! That said I'm bookmarking your answer, could come in handy down the road. Thank you.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

instantiate keeps repeating itself 0 Answers

Vector3 is not receiving enough arguments from a another script that gives out transform.position. 1 Answer

Falling object respawner 1 Answer

Unity standard assets 2018.4 Aircraft Ai isn't working on my own 3d airplane model. 0 Answers

3D Pong Clone: Set position of a Rigidbody, or change how a speed vector is verified? 1 Answer