# 3D Collision physics problem, still having trouble

Started by Oct 09 2001 03:43 PM

,
3 replies to this topic

###
#1
Members - Reputation: **122**

Posted 09 October 2001 - 03:43 PM

ok, this is what I need, since I am still having a hard time solving this...
what we know,
Xangle, Zangle of terrain slope
X,Y,Z velocity
when there is a collisiont with the terrain,
// do a bunch of stuff,
X,Y,Z is now the NEW velocity vector.
so, what is the ''bunch of stuff'' I would do to make this so?
an equation is what I need
Thanks everyone for the help!!!

###
#2
Members - Reputation: **491**

Posted 09 October 2001 - 06:27 PM

You need the normal rather than the angles. You can create two vectors from the two angles as (cos(xangle),sin(xangle),0) and (0,sin(zangle),cos(zangle)) which are both unit vectors and their cross product is a unit normal. Which direction the cross product goes depends upon whether it is a left or right handed coordinate system.

The most straight forward way I can think of to get the new direction is to convert it to a coordinate system in which the collision point is the origin with the velocity and normal vectors within a plane formed by two of the axes, i.e. xy, xz or yz planes. Your normal would be one of the axes. The cross product of the normal with the velocity vector and the normal would give you another once you convert it to a unit vector. The cross product of the normal and that second axis would give you the third axis. That would give you the information to construct a transformation matrix. If you run the velocity vector through that transformation matrix you will get a vector that is in the plane formed by the normal and third axis. If you then reverse the sign of the component of the velocity vector in the direction opposite the normal then you have a velocity vector reflected across the normal. If you run that through the inverse of the transformation matrix you will be back in your original coordinate system.

The most straight forward way I can think of to get the new direction is to convert it to a coordinate system in which the collision point is the origin with the velocity and normal vectors within a plane formed by two of the axes, i.e. xy, xz or yz planes. Your normal would be one of the axes. The cross product of the normal with the velocity vector and the normal would give you another once you convert it to a unit vector. The cross product of the normal and that second axis would give you the third axis. That would give you the information to construct a transformation matrix. If you run the velocity vector through that transformation matrix you will get a vector that is in the plane formed by the normal and third axis. If you then reverse the sign of the component of the velocity vector in the direction opposite the normal then you have a velocity vector reflected across the normal. If you run that through the inverse of the transformation matrix you will be back in your original coordinate system.

###
#3
Anonymous Poster_Anonymous Poster_*
Guests - Reputation:

Posted 14 October 2001 - 12:29 PM

the bunch of stuff depends on your physics model.

do you want your guy to bounce or stick. slide or skid.

yaw or pitch. its really up to you. there isnt an equation

that can tell you how to solve these problems. you need

to solve them based entirely on how you want whatever your

doing collision checks against to behave.

ahh the beauty of games...

do you want your guy to bounce or stick. slide or skid.

yaw or pitch. its really up to you. there isnt an equation

that can tell you how to solve these problems. you need

to solve them based entirely on how you want whatever your

doing collision checks against to behave.

ahh the beauty of games...

###
#4
Members - Reputation: **122**

Posted 14 October 2001 - 05:24 PM

yeah, thx guys for the help, I''ll just find some way to get it tow workl....... its not that I dont get the physics of it..... I do! my equations SHOULD work, its just converting physics to code

anyway thx for the help, I get this done and my game will ROCK, I promise

ok bye

anyway thx for the help, I get this done and my game will ROCK, I promise

ok bye