Flight Simulator Tutorial #3 – scene rotations and translation

This section deals with a simple method of creating the appearance of scene movement during the flight. Beside reviewing standandard rotation and translation formulas described before on this blog, the presentation begins to explain how to apply numerical-like methods to create a live and interactive model.

1. george says:

I thought about all those things two years ago during the roller coaster age, but they are not worth my time. I have too much on my hands right now. Today I need to post another one and be done by the end of the week. I will install instruments (3 tilts) speed and altitude gauges few buildings perhaps and maybe some very basic physics. Within a month I will make an RC simulator and that will be way cooler, since the plane will fly around you. Then the scene is not so important and it is challenging to fly too. In-cockpit simulators are boring anyway unless one flies close to a very eleborate scene (which in Excel is unfeasible). I don’t want to get people bored with too much of this simulator stuff. The principle is much more important than some polish. There are lots of people who can program much better looking landscapes using all sorts of tools but there is not much explanation out there about the elementary principles behind perspective change. An open spreadsheet with simple formulas in a 2D form (rather that VBA linear code) I believe is very useful and that’s what I offer. Otherwise what do you think? Did you try it in 2003? I know in 2007 is extremely slow. The only chance for speed would be a 10×10. Peter, could you please reply to the next post, let’s move out of here?

2. Peter says:

If you allow the value defining the horizon (to left and right) to fall outside the vertical range of your chart, you can get to quite high values of roll/tilt. Life gets difficult as you approach 90deg and inverted flight will require a complete revision of the chart. Gradient fills to lighten the sky color near the horizon and to fade out the land can look good but adjusting the angle with roll is just another headache.

3. george says:

Thanks Peter, that is a great idea. I’ve tried it and it will easily work for a 2D simulator (car) since it is hard to tilt. I can probably do some tricks though, but it won’t be easy.

4. george says:

I’ve been thinking for a ling time to introduce a giant ball and vary the center’position to get any angle possible and approximate the rim with a straight line given its huge size but your idea is far better and easier to implement. I don’t ever use area charts but I will figure it out.

5. Peter says:

I like polished.

Could you simplify the foreground detail if you superposed your scatter chart on a 2d area chart which infills the land/sky in much the same way as an artificial horizon?

6. george says:

Peter, the planetary is completely a separate model but very polished.
I got the flight simulator running. Forgot an absolute reference and wasted few hours to find it. I’m not dissapointed!!! Great stuff but slow after I put it together (about 7 frames per second with display and 10 without). I might improve it a little but not much since I will be putting control instrument panel, perhaps a cannon and radar and of course some enemy UFO’s. It’s gonna be one of my best models.

7. Peter says:

Sounds promising.

My thoughts on the large rotations (with delta t not very small) is that the result depends on the sequence in which the controls are assumed to have been applied (pull up then roll does not result in the same balanced turn as roll, then pullup). The small angle approximation based upon angular velocities could even be a more accurate model for the situation where the two controls are actuated simultaneously.

I will have a further look at the 3-body system – the basis for studies on chaotic motion perhaps?

8. george says:

Peter, I decided to finish the basic functionality before posting more. I am getting about 90 frames/second with joystick on and 41×41 verices, full processing (1 translation, 2 rotations + u-v conversion but no display yet). The display is supposed to bring the speed to mabe half or a third of that. I plotted the thing and it does not look right but I will figure it out by tonight. The joystick functionality is great though, I can loop and roll :-).

If the time step is very small it should be fine (doing cosA := 1 and sinA := A) but the game might be on the slower side. However you can live with some errors, no problem so the approximation must be all right even for larger time steps. On the other side I don’t think there is a speed problem since I calculate cos(pi()*pitch/180), sin(pi()*pitch/180), cos(pi()*roll/180), sin(pi()*roll/180) in a unique location in the worksheet and use those numbers in the rotation formulas. In my past experience I have not see significant differences in speed though by doing so but I think it’s a good practice. However if you pay attention to all the formulas and work it as a strategy throughout the sheet you can definitely improve speed. I did this on: http://excelunusual.com/3-body-planetary-system-with-options/.

9. Peter says:

So all is under control then. I was concerned by repeated manipulation of large arrays rather than getting the preliminaries done with the smaller transformation matrices. If the additional operations are fast then there is no issue.

On a separate issue, do you think it would make any difference to the behaviour of the simulation if you replace the large angle rotations used for the incremental update by small angle approximations? That is cosA := 1 and sinA := A.

10. george says:

You don’t have to but if you do you gain a lot. If you read carefully, I said in the tutorial that there are 2 ways. I didn’t go into details which is the second way but it is the standard way (without the paste). You don’t need to paste in the second one but you need to determine the 6 position parameters first (I would use a V shaped traveling form, apply the incremental controls and after that I would use basic trigonometry to determine the final 3 coordinates and 3 angles) and than apply back the 6 transformations to the whole image. It is a tutorial so I chose the simplest and natural way to do it (and easier to explain to beginners) which is 2 rotations + 1 translation (hence 1/2 calculations of the full method you are suggesting plus far easier to explain – most of people are light on math and geometry). The method I’ve chosen is the the smart way to do it, it does requires paste which is fast but it’s very light on calculations. Check out some of my heat models which run at 50-70 frames per second on 50×50 arrays using the same method. Of course charting really limits the speed to maybe only 30 fps. I started the full method (without paste) but I realized I would get bogged down in explanations for too many posts. I will do the full method but for the RC version (out of cockpit simulator). In the end I will benchmark them but it won’t be fair since the RC one does not change the landscape position. Thanks for the comment, George

11. Peter says:

George
I am still here. You have not convinced me of the need for three vertex meshes and cut and paste. Surely, it should be the transformation matrix (translations and rotations) that are incrementally updated so that the display is always derived by transforming the ground vertices.
Peter