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.

 

Slide64.JPG

Slide65.JPG
Slide66.JPG

Learn in your speed, with individual attention - Teachoo Maths 1-on-1 Class


Transcript

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.

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 13 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.