Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Collision Detection > 8.3. Ray Casting

8.3. Ray Casting

As an alternative to bounding areas, you can use ray casting, which is more precise than bounding areas, to detect collisions. The application shown in Figure 8.5 uses ray casting to determine if the ball falls into the bucket. The application consists of a simple launch pad on the left and the bucket on the right. When the application starts, the ball rests on the launch pad. When a user clicks the mouse, the application launches the ball in the direction of the mouse cursor, with a velocity proportional to the distance from the cursor to the launch pad.

image

Figure 8.5. Ray casting

Ray casting is simple: You cast a ray from an object coincident with the object’s velocity vector. Then you cast another ray from another object and see where the two rays intersect.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint