ScratchData LogoScratchData
Back to ChromeCat_test's profile

Line segment - AABB intersection

CHChromeCat_test•Created July 10, 2022
Line segment - AABB intersection
9
6
132 views
View on Scratch

Instructions

A snippet code to use when you need to test if a line segment intersects with an Axis-Aligned Bounding box (AABB) This uses only 46 operations which means it's quite efficient. (it can probably be done in even less but this is good enough for now)

Description

How it works: We first convert the line segment to parametric coordinates with parameter t. Then we check for each edge of the AABB whether the x/y value lies within the t bound of the line segment.

Project Details

Project ID713106174
CreatedJuly 10, 2022
Last ModifiedJuly 10, 2022
SharedJuly 10, 2022
Visibilityvisible
CommentsAllowed