#### Archived

This topic is now archived and is closed to further replies.

# Collision Detection...

This topic is 6179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi. I''m writing a 3D engine, and everything was going OK, until the other day. It''s my first attempt, and I haven''t written any collision detection code before. I''ve researched some different ways of doing it, and I''m using the dot product system, whereby you calculate to see if the player has passed a plane, so if the point is in the halfspace behind all the hyperplanes, it''s inside the object. But I''m having a problem with the formula: DotProduct(Polygon.Normal, Player.Position) + Plane.Distance I can''t calculate the minimum distance of the plane the triangular polygon lies on from the origin. I have managed to do it with polygons in the three major axes, x, y and z, but not with any others. I think I have to calculate the plane equation from the points of the polygon, and then I can find the minimum distance, but I''m not sure how to do this...can anyone help? I got the method above from http://www.flipcode.com/tutorials/tut_collision.shtml, if you want some clarification on what I''m talking about. The above formula is about 1/4 of the way down the page...

##### Share on other sites
An easier way to do this is as follows:

// assume that v1 is a vertex in your polygon
DotProduct(Polygon.Normal, Player.Position - v1);

If the dot product is negative, the player is "inside" the halfspace.

FragLegs

##### Share on other sites
Thank you, thank you, thank you! Now, I can finish my collision detection, and start on the physics!

##### Share on other sites
That was me, by the way, I forgot to sign in, damn it...

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633368
• Total Posts
3011531
• ### Who's Online (See full list)

There are no registered users currently online

×