ScratchData LogoScratchData
Back to Naboosf's profile

Point in Quad

NANaboosf•Created January 16, 2014
Point in Quad
13
11
371 views
View on Scratch

Instructions

- Drag the blue points to change the shape of the quad - Drag the red point around

Description

This demonstrates a method that checks to see if a point lies inside of a quad or not. It can be useful to do this when checking for collisions between a point and a hitbox. Unfortunately, concave quads will mess things up... sorry about that! How it Works: The program is finding the areas of 4 triangles. The four triangles share a common vertex: the red point, or the moving projectile. The other two vertices of the triangles are two vertices from the quad, each triangle using different sides of the quad. The sum of these triangle areas are compared to the area of the quad itself, and if the former of the two areas is less than or equal to the latter, the point is inside the quad. Enjoy!

Project Details

Project ID16656476
CreatedJanuary 16, 2014
Last ModifiedApril 29, 2014
SharedJanuary 17, 2014
Visibilityvisible
CommentsAllowed