A pig farming firm that sued a hot air balloon company claiming one of their flights caused a fatal stampede among their animals used a maths whizz to win a £40,000 payout.

Farmers Ian Mosey (Livestock) said a hot air balloon had scared their pigs into a stampede - resulting in three sows suffering heart attacks and a boar dying from his injuries the next day.

But the compensation was only secured with the help of a university maths professor who used trigonometry methods to prove their case.

The balloon, from Wiltshire-based company Go Ballooning, was flying over Low Moor Farm in North Yorkshire in April 2012 when it descended so low and fired its burners that the animals stampeded in fright.

The herd of pigs fled to a corner of the field during their ordeal and ended up piled together in a ditch.

Following the incident the surviving pregnant sows suffered a number of aborted piglets and stillbirths.

One issue in the dispute related to the exact location of the balloon in relation to the animals – the insurers for the company providing the balloon ride used GPS data generated during the flight to claim that the balloon didn’t come closer than 750 metres from the pigs, and so could not have caused the stampede.

But the case was solved by Professor Chris Fewster from the Department of Mathematics at the University of York, whose report put the balloon at around 300m from the pigs when it fired its burner.

Following Professor Fewster’s report, having made an initial offer of £10,000, the balloon company’s insurers have now agreed a settlement of £38,782.

Dan Gilbank, manager at the farm, said: "The farmer's wife decided to take the photo of the balloon because she thought it was a nice picture. Luckily, it ended up having a key role.

"The company denied they had been anywhere near the pigs because they knew they were meant to steer clear of the farm. The Civil Aviation Authority ordered

that they were not allowed to come within 500m of the livestock, which they did."

Mr Gilbank said the noise of the burners caused chaos on the farm.

He added: "It was horrendous. There were three batches of pigs, all at different stages of pregnancy, that ended up in the ditch together. Three had heart attacks and died and about 70 per cent aborted.

"We saw the balloon heading over and there was nothing we could do. We hoped they wouldn't put the burners on but they did.

"We had to deal with the aftermath and it was inevitable with the shock that they would abort. It's nature."

Mr Gilbank, who has run the farm for the past 16 years, said it had a massive affect on the production of the farm - which aims to produce 600 piglets every three weeks.

Prof Fewster said: "I received an email from the solicitors with the picture attached and the first step was to see if we could work out where the balloon was. What we had to do was get some of the data out of the photograph like the lie of the land, the height of some of the trees in the background and the size of the balloon, most importantly. Then, putting all of that together with fairly elementary mathematics, nothing too difficult, we got to the answer."

He added: "The balloon was 27-and-a-half metres in diameter and that is why it was so scary for the pigs. It's a huge thing.

“The wonderful thing about mathematics is that it helps us think clearly about the world. This case shows how even relatively simple mathematics like trigonometry can make an important contribution.

"I am delighted to have helped the parties arrive at a settlement.”

Darren Morgan, dispute resolution partner at Langleys Solicitors, said:

“This was a particularly interesting case because the exact position of the hot air balloon in relation to the herd of pigs would have been almost impossible to prove without both the initial photographic evidence, and the subsequent calculations from Professor Fewster.

The hot air balloon company, also known as Cameron Flights Southern Limited, went into liquidation in April 2013.