#### Archived

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

# Positions

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

## Recommended Posts

Since no one understood my collision detection problem I have made a site with pictures, etc. The pictures are big and might take long to load. Plz check it out and if you can help me. The url is - http://home.iprimus.com.au/laser1/help.htm

##### Share on other sites
Did you really have to upload all those images as .bmps instead of .gifs or .jpgs or something? That page took AGES to load.

Now I''d like to help, but I still don''t really understand your problem. I haven''t used D3D before so I don''t really know what all those D3DX functions do.

I can tell you however that this piece of code you posted on that site (which I couldn''t find in your .zip file btw) is utterly useless. Why it is useless? Well all statements do exactly the same. See the comments I added:

  if (point.x < 0){ if (pos.x < 0) { if (pos.x > point.x) { posold.x = point.x + (point.x-pos.x); // = 2*point.x - pos.x } else { posold.x = point.x - (pos.x-point.x); // = 2*point.x - pos.x } } else { posold.x = point.x - (pos.x-point.x); // = 2*point.x - pos.x }}else { if (pos.x > 0) { if (pos.x > point.x) { posold.x = point.x - (pos.x-point.x); // = 2*point.x - pos.x } else { posold.x = point.x + (point.x-pos.x); // = 2*point.x - pos.x } } else { posold.x = point.x + (point.x-pos.x); // = 2*point.x - pos.x }}// Conclusion, this whole block of code is identical to:// posold.x = 2*point.x - pos.x;

I''m sorry I can''t help you on your method. But I would seriously suggest you look into creating your own collision function which uses a real bounding box. Just checking the vertices of a bounding box is not enough. (Imagine a long car colliding with a narrow building. All the bounding box vertices could be outside the building while the building still penetrates the car.)

If you want some help with that, just ask.

##### Share on other sites
This is a classic problem that has been responded to several times on this forum. Your object''s velocity is such that in the interval between collision test the object may have passed through the boundary. The solution is to determine when the object will collide (using the velocity vector and the surface in the direction - intersection of a line and a plane) and calculate where the object should be at the next interval (frame, for example). Hope that made sense to you.

##### Share on other sites
Hey,
Scarab0 why do all the statements end up being
quote:

posold.x = 2*point.x - pos.x;

Can you fix this code up.
Thanks

Edited by - flashlaser on October 19, 2001 6:34:01 PM

##### Share on other sites
Well you have only two different statements:
posold.x = point.x + (point.x-pos.x);
and
posold.x = point.x - (pos.x-point.x)

You should know from simple math that:
posold.x = point.x - (pos.x-point.x)
posold.x = point.x - pos.x - -point.x
posold.x = point.x - pos.x + point.x
posold.x = point.x + point.x - pos.x
posold.x = 2*point.x - pos.x

And also that:
posold.x = point.x + (point.x-pos.x)
posold.x = point.x + point.x + -pos.x
posold.x = point.x + point.x - pos.x
posold.x = 2*point.x - pos.x

Thus, both statements are equal. I hope you understood that, I'm not terribly good at explaining things.

I wouldn't know how to fix it up though, since I'm not quite sure what that block of code is supposed to do.

EDIT: typo's

Edited by - Scarab0 on October 19, 2001 7:24:14 PM

##### Share on other sites
Scarab0,
I thought since I put bracks around the (pos.x-point.x) it would be done first and the result subracted from point.x/

##### Share on other sites
Scarab0,
I thought since I put bracks around the (pos.x-point.x) it would be done first and the result subracted from point.x/

##### Share on other sites
It''s like saying 5 - (3 - 2) and 5 + (2 - 3). The result is the same (4). The reason why is that addition is commutative (a+b = b+a) and multiplication is distributive (a*(b+c) = a*c + b*c). -(a + b) is the same thing as -1*(a + b), which is (-1*a) + (-1*b).

##### Share on other sites
Couldn''t have said it any better myself Oluseyi!

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 35
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631702
• Total Posts
3001812
×