please remix, luv, fave, and follow. Reach 50 faves and 50 likes and I'll make square vs line collisions! Math ~~~ This calculates a collision by finding the distance from the line to the circle, perpendicular to the line (also known as the tangent). The tangent is the blue line. the tangent = yellow line's length * sin of (the angle between the white and the yellow) this angle can be marked as B B = acos(Yellow^2 + Pink^2 - white^2 / 2 * Yellow * Pink) since scratch's pen is measured with it's diameter, we divide by 2 to get the radius: If Blue < Circle's diameter + line's diameter / 2: Then: Collision = true But what about when B is greater than 90 degrees? Or when the angle between the Pink and the white (let's just call it "A") is greater than 90 degrees? if the angle B is greater than 90 degrees then the tangent = yellow if the angle A is greater than 90 degrees then the tangent = pink This gives us the circular end of a pen line. (:
All coding and math from me. Advertisements will be deleted if found. Advertise here instead :D https://scratch.mit.edu/studios/51921611 This method of collision detection uses trigonometry. It's inefficient unless you want to make your collision detection scripts look more complex, but I'm making a process that uses heron's formula which is a lot more easy to understand than this. As complex as the code looks, this method of collision detection can be really useful. I've already made a raycaster with it.