March 10, 2017

Evolution of helicopters in the Vietnam War

0 comments
The Vietnam War was the first conflict where helicopters played an important role. While the future Cold War battlefield in Europe would have consisted of great tank battles, the jungles of Vietnam prevented tanks from moving efficiently. There were American tanks in the Vietnam War, but their main purpose was to keep roads clear from the enemy by using a tactic called Thunder Run, which is the same tactic that years later would be used by American tanks to capture Baghdad.

Tanks in the Vietnam War were always staying close to roads because a tank in a jungle is a big target for the enemy. But the tanks would clear jungle close to roads if needed. There's an example of a helicopter that crashed in the jungle. To rescue it, tanks on a nearby road were ordered to move through the jungle and secure the crash site. And if the enemy had built a bunker, a tank would drive up to the bunker, stick the barrel into the bunker, and fire. But again, these bunkers had to be close to roads or the tank would simply not be able to get there.    

With tanks out of the picture, the US came up with the idea to use helicopters. In the Korean War, the main purpose of the helicopter was to transport wounded to the rear two at a time. But when the Vietnam War happened, technological improvements had transformed the helicopter to a fighting machine, so they were no longer just transportation vehicles. A guy called Jim Gavin wrote an article called "Cavalry - And I don't mean horses" where his vision was that bigger, faster helicopters could carry infantry into the battle and make it a three-dimensional nightmare for an enemy commander. US decided to add helicopter transported infantry to it weapons of choice, and the recently developed Bell UH-1 Iroquois (nicknamed Huey) was chosen as the main helicopter for this unit:

The Huey

The helicopter transported infantry was sent to Vietnam. But if you've seen the movie We Were Soldiers, you know that helicopter transported infantry wasn't a three-dimensional nightmare for an enemy commander. If the enemy could cut off the few landing zones available in the Vietnamese jungle, where the helicopters could land, the infantry would be on its own. Each Huey has two machine guns operated by relatively unprotected soldiers, so the damage they could make was limited. The solders on the ground could get support in the form of artillery and air support from winged aircraft, but this support wasn't accurate enough to rescue the infantry in all situations. So something else was needed.

The Huey was a great helicopter, so someone realized that it was possible to take the basic engine and rotor, but add a new body to get a helicopter that could support the infantry. So the Bell AH-1 Cobra was quickly developed and would arrive to the Vietnam War.

The Cobra

The Cobra could kill the enemy but it couldn't find it. So someone came up with idea idea that you could combine the Cobra with the smaller, but much more agile helicopter Hughes OH-6 Cayuse (nicknamed Loach). Now you would get a so-called hunter-killer team, where the Loach was finding the enemy and the Cobra was killing it. The Loach could seat five: two pilots and three passengers. But in the Vietnam War, the Loach had either two pilots and one gunner, or one pilot, one gunner, and one mini-gun fired by the pilot. Why not four in the helicopter and a mini-gun? Because that would make it too heavy!

The Loach

One of the pilots who flew a Loach as part of a hunter-killer team in the Vietnam War was Hugh Mills. He wrote about his experiences in the book Low Level Hell - A scout pilot in the Big Red One. A helicopter scout in the Vietnam War had the following jobs:
  1. Find enemy base camps, fighting positions, supply caches, trails, and other signs of enemy movements.
  2. Assess damage made by high-altitude bombers, such as the B-52.
  3. Find landing zones for the infantry carried by the Huey helicopters.
  4. Help the infantry and tanks on the ground by giving them information, such as which terrain is the most advantageous, and if the are moving in the correct direction.

If you are a scout pilot (the hunter), the easiest way to find out where the enemy is hiding is to fly as close as possible to where you think the enemy is and hope that the enemy will fire at you. If you are fired at, then you drop smoke, so the Cobra (the killer) know where the enemy is and can fire the rockets. The result of this suicide tactic was that Mills was shot down no less than sixteen times and wounded three times.
Though I was getting shot at almost every day, I never got used to it. But getting shot at was usually the way a scout found the enemy, and finding the enemy was our basic job.

It might sound strange to sacrifice one helicopter, while the other helicopter is waiting for the scout the be shot at. But the pilot in a Loach has a better view of the surroundings, and the Loach is also a smaller helicopter making it more difficult to hit, so the tactic makes sense. To help the Loach, the Cobra was always staying within sight of it and did everything the pilot in the Loach didn't have time to do. The Loach pilot had to fly the helicopter while having his eyes constantly focused on the ground, so the Cobra read the map and transmitted radio messages.
The good scout pilot never stops talking to his gun [the Cobra] from the moment he goes down out of altitude until he comes back up again. It not only keeps the Cobra happy and informed, but it tends to keep your own guts stabilized when you're down low working and, at any instant, could catch a bellyful of AK-47 fire.

March 5, 2017

One of the greatest intellectual achievements of history

0 comments
How are you making a rope in a computer game? The most common answer to the question is: you approximate the rope with springs. This may first sound a crazy idea because you don't want a rubber band but a rope and a rope is not bouncy. But the truth is that all materials can be approximated with springs. When the famous entrepreneur Elon Musk first wanted to learn how to design rockets, he read the book Structures: Or why things don't fall down. It says:
The idea that most materials and structures, not only machinery and bridges and buildings but also trees and animals and rocks and mountains and the world itself, behave very much like springs may seem simple enough - perhaps blindingly obvious - but, from [Hooke's] diary, it is clear that to get thus far cost Hooke great mental effort and many doubts. It is perhaps one of the greatest intellectual achievements of history.

So if you know how to make a rope, you will also know how to make cloth. To make cloth, you just add more springs in other directions. This is also how Pixar is simulating hair in their animated movies: by approximating hair with springs.

I've been prototyping a helicopter game. The helicopter has a winch so it can winch people up from a stormy sea: 


It took a while to figure out how to make a realistic rope in Unity with C# code, so I've summarized it in a tutorial: How to create a swinging rope tutorial in Unity. You will learn how to make two different ropes:
...and this is the difference between the results: 

Realistic rope

Simplified rope

You should use the more realistic version if you are making a rope with low mass and the rope can collide with the surroundings. But if you increase the rope's mass in the realistic version then you have to increase the spring constant if the rope is going to keep its original length. But now you will encounter something called numerical instabilities, and you will observe how the rope is going out of control and finally "explode." Explode means here that the numbers are growing exponentially until they get so large that the computer can't handle them anymore.

So if you are making a helicopter winch where the wire is made out of metal and you have to winch heavy people out of the sea, then you need to use the more simplified version. The idea behind the simplified version is that you use one of Unity's built-in Spring Joints. If you add more or less rope, then the spring constant and damping constant have to be recalculated, and then you just add the new values to the Spring Joint. To actually add more or less rope you just change the Spring Joint's max and min distance. 

But you also need to make a curvy rope - the rope shouldn't be a straight line from the start of the winch to the basket. Now you have two alternatives:
  1. Use the ideas from the more realistic rope and add it between the start of the winch and the basket. This rope can have "fake" values to avoid numerical instabilities, while still looking as a real metal wire. 
  2. Use a Bezier curve and change the control points based on the rotation of the basket and the rotation of the helicopter. This will look like a real rope, will be fast to generate, but the most important difference is that you will never encounter numerical instabilities when generating a Bezier curve. So this solution is more robust while still looking like a real rope would look like. If you lower the altitude of the helicopter, you will get the characteristic shape of a rope falling down - the rope will bend like a real rope would: