# coordinates transformation

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

## Recommended Posts

I have bounce ball physic implemented when normal to the bouncing surface is (0,1,0). Instead of writing new algorithm which would work for other normal vectors I could resuse my algorithm and transform input data like velocity vector.

http://zapisz.net/images/453_problem.jpg

##### Share on other sites

Assuming you're trying to calculate a reflection vector:

Vreflection = V - 2 * (n dot V) * n

for any n.

##### Share on other sites

In case that you really want to do more than calculating the reflection vector, and only translation and rotation but not scaling plays a role:

All your vectors are given in a space described by the identity matrix, i.e. with

o = [ 0 0 0 1 ]t

x = [ 1 0 0 0 ]t

y = [ 0 1 0 0 ]t

z = [ 0 0 1 0 ]t

The other space is described by

o', x', y', z'

What you want is a transform M that maps the original space onto the given one:

o' = M * o

x' = M * x

y' = M * y

z' = M * z

Because each of oxyz has a single 1 and otherwise 0s as elements, and the 1 is stored at different rows, each of those mappings above just pick a single column from M:

M * x = M * [ 1 0 0 0 ]t = M1st column

M * y = M * [ 0 1 0 0 ]t = M2nd column

M * z = M * [ 0 0 1 0 ]t = M3rd column

M * o = M * [ 0 0 0 1 ]t = M4th column

In other words, the transform M is the matrix

M := [ xyzo' ]

If you want to transform a vector v from the original into the mapped space, you have to apply

v' = M * v

If you want to transform a vector v' from the mapped into the original space, you have to apply

v = M-1 * v'

Edited by haegarr

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633407
• Total Posts
3011699
• ### Who's Online (See full list)

There are no registered users currently online

×