Live data from Hacker News

Translating a Fortran F-16 Simulator to Unity3D

vazgriz.com

51–60 of 129 posts

Re: Translating a Fortran F-16 Simulator to Unity3D

#51

When I was growing up computers were getting faster by leaps and bounds, and I remember a video game that was so 'sophisticated' that it needed a math (FP) co-processor (80387) to play some parts of it: > The program requires a minimum of a 12MHz 80286, 1MB RAM, DOS 5.0 or DR DOS, one 1.2MB 5 1⁄4" or 1.44MB 3 1⁄2" disk drive, hard drive with 11MB of free disk space, and VGA graphics. In addition, Falcon3.O supports a…

Falcon game still have a large following today.

Most people play Falcon BMS which is a mod of Falcon 4.

https://www.falcon-bms.com/

Re: Translating a Fortran F-16 Simulator to Unity3D

#52
Awesome read except I have one nit. Instead of writing translating functions to convert everything from US Customary units to Unity, Metric, and the rest of sanity, you should have converted everything to metric in the formulas. Rewritten the math. It's not that hard, it's not that difficult, saves you all those function calls, improves performance, and simplifies the math a whole bunch.

Air density can become pliable, controllable. Thrust velocities match projectile spec velocities (m/s) making calculating intersect a breeze. Trust me, you want to convert the FORTRAN math into standard metric. They didn't believe in Base10 back then so do the math.

Re: Translating a Fortran F-16 Simulator to Unity3D

#54
post #18

Earlier quoted context omitted.

I'd agree with 1-based indexing problems, but not 0-based, which seems very natural. And if you have -2-based, I'd argue that perhaps you don't want an array.

I think it's down to personal preferences/how you think. I haven't actually used any languages that didn't have 0 based indexing, but I remember it being very painful and super unintuitive to learn, it just didn't make sense at all (still doesn't, but it's not a problem for me anymore). I always thought 1 based would make a lot more sense and be way easier to learn.

I would say it is sensible. Given that an array index is an unsigned integer, what are you going to do with an index of zero?

Perhaps I've been influenced by writing a lot of code in assembler, way back when, but zero-based has always seemed completely natural to me, to the extent that I find it very hard to understand algorithms expressed in non-zero based code.

Re: Translating a Fortran F-16 Simulator to Unity3D

#55

Earlier quoted context omitted.

I think it's down to personal preferences/how you think. I haven't actually used any languages that didn't have 0 based indexing, but I remember it being very painful and super unintuitive to learn, it just didn't make sense at all (still doesn't, but it's not a problem for me anymore). I always thought 1 based would make a lot more sense and be way easier to learn.

I wonder how many of the "off by one" issues/bugs we encounter in the wild are because of arrays typically using 0-based indexing vs 1-based indexing.

None, in my experience. 1-based is far, far likely to introduce errors, as you have to keep adjusting the index to the algorithm and/or what is actually going on underneath.

Re: Translating a Fortran F-16 Simulator to Unity3D

#56
post #2

The "UNITS" part is wonderful. I had no idea slugs even existed. You want to measure how much air mass is in a given volume? That’s gonna be slugs/ft3.

The 'List of non-coherent units of measurement' [1] and 'List of humorous units of measurement' [2] pages are always a fun rabbit hole to go down. [1] https://en.wikipedia.org/wiki/List_of_non-coherent_units_of_... [2] https://en.wikipedia.org/wiki/List_of_humorous_units_of_meas...

Ah, I now learned that "One moment, please" means that I'll have to expect to wait 90 seconds.

Re: Translating a Fortran F-16 Simulator to Unity3D

#57

Awesome achievement but I have to say the units stressed me out. I hope that in the real world there's some kind of dimensional analysis code linter that verifies no one is comparing slugs to feet or something, and that altitude doesn't go below zero.

In practice, unit checking is almost never done on actual code, though it should be done. From what I recall, some Fortran folks have been trying to get unit checking into the Fortran standard itself since the 1970s without success.

I was able to coerce Fortran's type system into checking units, but it comes with quite a few downsides: https://fortran-lang.discourse.group/t/compile-time-unit-che...

An approach based on static analysis would not have the downsides I listed, but I personally would prefer being unable to compile the code at all if it had an error that could be detected.

Re: Translating a Fortran F-16 Simulator to Unity3D

#58
post #6

> Note that Fortran supports arrays with an arbitrary starting index, in this case -2. So this table supports indices in the range [-2, 9]. That is such a useful feature! Surprised I haven’t seen that more often. So much fiddly code exists that’s just fixing offsets to conform to 0 (or 1 for Lua) -based indexing!

Unfortunately, Fortran's implementation of this has some inconsistencies. Doing certain operations will convert from the custom indexing back to 1-based indexing.

https://github.com/sourceryinstitute/fidbits/blob/master/src...

https://fortran-lang.discourse.group/t/just-say-no-to-non-de...

Re: Translating a Fortran F-16 Simulator to Unity3D

#59

My Mom was a FORTRAN programmer for a defense contractor from the late 50s to the mid 90s. She spent her career doing things like that F16 simulator. The last thing I remember her talking about was one of the B1 or B2 bombers. When I was elementary school age in the late 70s, I'd go into her office with her sometimes on school holidays that were not work holidays. She'd let me play Colossal Cave Adventure on a termin…

FWIW she probably wasn’t breaking any security protocols - basically as long as the kids can’t read well they are fine to be escorted without the red light.

I used to take my daughter into the SCIF when she was about 2 when needed, and there was a week where I was took my son into work at the Pentagon.

I working for Snake Clark at the time and people kept bringing him candies and treats. I think he was watching cartoons on Nick in the deputy’s office most of the day. He gets a kick out of that story now.

Re: Translating a Fortran F-16 Simulator to Unity3D

#60
post #50

I'm somewhat surprised the physical units matter in a computer simulation. As long as the simulation is internally consistent (which I would assume the original code is) it seems odd to me that the nominal units are important at all. Is that video game character walking 100 yards? Or maybe the character is 500 feet tall and he's walking 50 leagues?

Gravity doesn't scale this way. Earth's gravitational pull (~10m/s^2) is a constant that ties distance to time, so if you want to observe the same gravitational effects in the same gravitational pull on a small dimensional scale, you need to adjust the time scale to compensate. This is why scale model sets for practical VFX in cinema were always recorded at higher frame rates and then played back slower.

That's only a problem if you're dealing with real gravity shooting real models in a real physical world. In a simulation, you can set G to whatever it needs to be.

The acceleration defined to simulate gravity in this Fortran code is presumably already proportional to everything else defined in the simulation.

Post reply on HN