Research – Array, Lists, Pythagoras & Vector Normalisation

Another bunch of research for Ant’s Unity class that will help us a) understand how maths is used and calculated in Unity and b) to help us on the coming test.

Pythagoras:

The simplest way to understand Pythagoras is a2+b2=c2. (the free wordpress account apparently doesn’t have the proper squared symbol but I’m sure you’ll know what I’m on about).

Basically; ‘The square on the hypotenuse is equal to the sum of the squares on the other two sides’.

The hypotenuse is the longest side of a triangle and is always directly opposite of the triangle’s inner right angle.

However, Pythagoras only works for right angled triangles.

In terms of videogames and how Unity applies it, Pythagoras is used to determine the distance between two objects. Also, this length is sometimes referred to as a ‘vector’, and the ‘magnitude of a vector’, is simply referring to its length; in this case, the distance between b & c.

Vector Normalisation:

Vectors can be normalised to change its magnitude to one. The vectors are commonly referred to as unit vectors because they are 1 unit in length. Vector units are preferable to variable length counterparts when working with vector lengths.

When you normalize a vector you make the length of it equal to 1. To normalize you divide the x, y and z co-ordinates by the length of the vector. This then gives you the Unit Vector.

Arrays & Lists:

Array data type is used in a programming language to specify a variable that can be indexed

A variable array is arrangement of items which are at equally spaced addresses in a computers memory. Being a variable, the value can change or vary but each item can only hold one item of data.

So if a score in a game needs to record ten scores, the data can be written for each score, as shown in the below left picture. But to keep all of the data under one name, an array is used which replaces the need for ten individual pieces. – below right

Lists are a data structures similar to arrays which allow more than one type of data or multiple pieces of data at once. It can also be a variable which hold multiple other variables. A list consists of a numbers paired with items and each item can be retrieved by the number assigned to it.