Raycasting is a technique used in the creation of computer games. The basic idea of raycasting is as follows: the map is a 2D square grid. Using rays generated from an object, this 2D map can be transformed into a 3D perspective. One of the methods involves sending out a ray from the player's location. To determine how far he/she is from a wall or an obstacle, the distance between the player's coordinates and the coordinate of the wall is calculated. If the player is near the obstacle, it looks larger and vice-versa.
Shown below is a game, Wolf 3D, which was created using raycasting.
Riju wants to create an online snooker game using raycasting. The game in the creation stage on a coordinate map is shown below.
The snooker table has six pockets (P1, P2, P3, P4, P5 and P6) and he has shown three balls - white (W), red (R) and green (G) on the table. The objective of the game is to use the white ball to hit the coloured balls into the pockets using a cue stick.
Question 37 ( i )
How much distance will a ray travel if sent from the green ball to the nearest pocket? Show your work.