Arrays, Lists & Pythagoras Theorem

Much like last week with class diagrams & trigonometry, Ant wants up to get a heads up on next weeks content. So here we go with some online research.

Arrays

Alright some of this seems to make a little more sense than class diagrams initially. From what I can gather an Array can be considered a collection of variables all with the same data type and all sharing the same name (the name of the array).

An example I came across used game scores as a means to explain. Say there were ten scores to hold in memory for a game, this would normally be ten variables. For ease we’ll say these would be gamescore1 through 10. Instead you declare one array variable of gamescore(10), the number in brackets determines how many data items the array will hold. A specific ‘variable’ in an array is accessed by an index.

Lists

So I looked up lists and immediately found this:

A list (also called an array in other programming languages) is a tool that can be used to store multiple pieces of information at once. It can also be defined as a variable containing multiple other variables.

So I guess the terms are interchangeable depending on the language you are using. The only difference I found is that arrays only store one type of data. So when the array is created if it was assigned int for example it can’t contain anything else. Whereas lists can contain more than one data type.

Pythagoras Theorem

Another concept I’ve not dealt with or used for half my life time. Much like trigonometry Pythagoras Theorem deals with right angled triangles and calculating lengths/missing sides but without the need for an angle.

“Pythagoras’ theorem states that for all right-angled triangles, ‘The square on the hypotenuse is equal to the sum of the squares on the other two sides’.”

Thanks for that quick description BBC.

small

So in short a² = b² + c²

The other sides work as follows:

b² = a² – c²

c² = a² – b²

To demonstrate:

small-1

We need the length of LM, which is c.

c² = 6² – 4²

c² = 36 – 16

c² = 20

c = √20

c = 4.5cm (1 decimal place)

As an extra note the theorem can also be used to determine if a triangle is NOT right handed since it only works with right handed triangles.

If a² < b² + c² the angle is acute (less than 90º)

If a² > b² + c² the angle is obtuse (between 90º and 180º)

Vector Normalisation

Until context is given this is confusing my very non logical brain. The basic part I can gather is to take a vector of any length and change its length to one while still pointing in the same orientation.

6ade290db694921cc465883fb070d8a1dbb3447e

The vector (or the hypotenuse it seems) would need to be divided by itself to get a value of one, you then divide the remaining sides by the same number to normalise those. I saw briefly some notes about using the process to simplify the vector math as you generate smaller numbers but I’m still not 100% sure of its full purpose.

653fdc7d4773c0b2844af3ed51e42debd6b4cb5f

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s