Trigonometry and Class Diagrams

In Ants lesson we went over trigonometry and class diagrams.

When using trigonometry in coding for games we learnt that we use Cosine and Sine differently to Tangent, Cosine and Sine is mostly used for movement where Tangent can be used to have a enemy turn and aim at a player, the example that we were shown was a 2d spaceship game. Without unity doing all of the maths for you the way you’d workout trigonometry is with the Hypotenuse, opposite and the adjacent on a triangle, with these you would divide to work out each thing needed. For example to workout the Cosine the equation would be  Adjacent/Hypotenuse.

In unity “Radians” are used instead of degrees when using trigonometry meaning when you need to convert in code its the “Deg2Rad” function, but if calculating yourself its Degrees/180 x Pi. This equation can be done to get Degrees by doing  Radians/Pi x 180, the function in unity would be “Rad2Deg” if needed.

Below is the gif that shows what exactly a Radian is, I think it shows it better than I could using words.

aquryb1

Class Diagrams is a way of planning something, in terms of games it can be used to plan everything from characters to vehicles. A class diagram is basically a system to show all the classes (Recipe(Instructions))for something needed, for examples you would have all of your information (Class files) that you need including movement health etc. After this you would list the functions that are needed to make these possible.

420px-uml_diagram2

 

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