Developers creating websites and desktop applications that interact with databases or mobile apps, often wonder about the use of maths. Not so for Game Developers. Math is one of the essential tools in our toolbox, and it enables us to solve problems fast and efficiently. This semester, DAE's first-year students are working with vectors and cross and dot product, and looking at applications where these are being used. One of the first examples we delved into was the use of dot product as a tool to determine the orientation of a face in relation to the camera. This enables a technique called back-face culling, where we only render the triangles that are facing the camera.
The next construct we analysed was the usage of the dot product to find the distance between a point and a plane.
As a variation, we also looked at the distance between a point and a line, using a similar technique.
Once the use and the application of dot product were understood in the context of 3D, games and game engines, we turned our attention to the cross product, in order to calculate the normals of a plane to gain understanding about right-handed or left-handed coordinate systems and what it means to change the unwinding order of triangles.
This same technique, the cross product, was used to determine the relative left and right side of a ship, floating arround in a top-down game. This comes into play when you want to steer a vehicle in games where the right and left steering depend on the vehicle's orientation.
Finally we looked at how to guide a projectile's course along a wall after impact.
These mathematical concepts where then used to implement diffuse and specular lighting, as explained in our previous article on Math in DAE.