# Determine new travel direction

1. May 29, 2013

### levydee

Using the given information, is it possible to solve the new travel direction of the smiley face? To clarify, I am casting a ray using the Möller–Trumbore ray-triangle intersection algorithm.http://http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm by casting the ray in the travel direction of the smiley face, I can determine how far away from said plane I am. When I hit that point, is their a mathematical way to, in this specific case, stop the x axis from advancing, and advance the z axis at half the rate?

If any clarification is needed please let me know.

Thank you.

#### Attached Files:

• ###### Math issue.jpg
File size:
8.5 KB
Views:
91
2. May 29, 2013

### Staff: Mentor

Which kind of interaction do you have between the wall and the smiley?
A perfect elastic collision? Reverse the x-component, keep the z-component.
Perfect inelastic? Set the x-component to zero, keep the z-component
Sticky? Set both components to zero
Something else?

3. May 29, 2013

### levydee

This is not necessarily a physics question. Elasticity is not a factor in the context of the intended use. Basically the plane is static and the smiley face is controlled by keyboard input(W,A,S,D). I can muscle in some bounding checks between objects, but I am looking for more of an eloquent solution. I am a programmer and am working on a physics engine. Collisions between dynamic bodies is handled else where.

4. May 29, 2013

### Staff: Mentor

In your code, you can set every component to everything you like, but most results will look unrealistic.

5. May 29, 2013

### levydee

Ok, so using the picture provided, assume my smiley face is moving at -10 arbitrary units on the X axis, and 10 arbitrary units on the Z axis. When the smiley face contacts the wall(knowing its travel vector and the planes normal), I want to now move at 0 units on the X axis, and move at 5 units on the Z axis. Just as an example. I guess I am looking for some formula, or algorithm to simulate that. Im sorry if I am in the wrong forums. I am just looking for some tips or opinions.

Thank you

6. May 29, 2013

### Staff: Mentor

Simulate what, in which way?
Let it move step by step? Then you just need the previous position and the current velocity for each step.
Calculate its position after some specific time? Simple algebra (addition and multiplication) with both components.

7. May 29, 2013

### Simon Bridge

I wonder of OP has misunderstood what is meant by "elastic"?
What happens in the collision depends on what type of collision you want - in a computer program you can pick any kind of collision you like and simulate it.
Therefore we cannot help you the way you want unless you make a decision here.

What would be wrong, for example, just "reflecting" the smiley off the barrier?
Do you want the barrier to be a bit sticky so the smiley loses some speed after the collision?
Do you want the velocity of the barrier to add or remove something to/from the smiley?

The short answer to the question in post #1 is "no", there is not enough information.