O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Pythagorean theorem

The most widely used triangles are right-angled triangles. There are many interesting properties of right-angled triangles that can be used in games to make life easier. One of the famous properties is that the square of the hypotenuse of a right-angled triangle is equal to the sum of the squares of the other two sides.

Getting ready

The hypotenuse of a triangle is the longest side of a right-angled triangle, as shown in the following diagram:

Getting ready

If the hypotenuse is denoted as h, the Pythagorean theorem can be written as follows:

h2 = a2 +b2

If you take the square root of both the sides, you will get the following:

h = sqrt(a2+b ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required