Today I learned how trigonometry is used for movement in coding and how to make class diagrams.
In coding, trigonometry is used to work out the distance an object travels based on X and Y axis. Only right angled triangles are used in coding. The Sine is the ratio of the length of the opposite side and hypotenuse, and it relates to ‘Y’ movement. The Cosine is the ratio of the length of the adjacent side and hypotenuse, and it relates to ‘X’ movement. The Tangent is the ratio of the length of the opposite side to the adjacent side, and it’s used to work out angles based on movement. It is most useful for working out angle changes, and under this scenario the opposite side is the ‘Y’ axis, and the adjacent angle is the ‘X’ axis.
Radians are an alternative way of measuring angles, similarly to degrees, except radians are used in coding. 1 radian is the angle covered by wrapping the circle’s radius around it’s own circumference. Pi rad is equal to 180 degrees, and 2Pi rad is the full circle (360 degrees). C# has a built in degrees to radians converter, and to use it you need the code ‘Mathf.Deg2Rad’, which also works the other way.
Class files/diagrams are a way of mapping out stats or properties an object will need. Classes are like recipes or blueprints, they are instructions you follow to make a thing. Class files also explain the actions (functions).