Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Help, intersection of a line with a non-unit sphere

Author
Message
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Feb 2013 10:38 Edited at: 17th Feb 2013 08:25
It's working, but I have a minor issue. The direction of the normal determines which side of the line the intersection happens. In 3D this is probably ok because you often won't be colliding with the backface of a polygon. But in 2D, I could hit these lines from any direction.

Swapping the normal to point the other direction is simple:
nx# = -nx#
ny# = -ny#


In my other collision examples, I've always just focused on the collision point right on the line itself, no need for normals making for much faster calculations. However, I need to detect for collision between lines and a ball of a given radius, so this was a different approach for me.

I read an article on gamasutra a few times and after awhile I believe I understand where their math came from to get these results. However, I'm trying to find out a way to place the ball on the side of the line it came from so I don't have to worry about the direction of the normal.

I know it's easy enough to determine which direction the ball is traveling in regard to the lines, but I was hoping to find a way to skip that check.




"You're all wrong. You're all idiots." ~Fluffy Rabbit
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Mar 2013 19:36
Solved!

"You're all wrong. You're all idiots." ~Fluffy Rabbit

Login to post a reply

Server time is: 2026-07-07 02:39:59
Your offset time is: 2026-07-07 02:39:59