Search code examples
algorithmgame-physicscoordinate-transformation

rotating coordinate system with time


I am not sure if this is the correct place for my question, but I'll give it a shot. I guess it is somewhere between CS and physics, but since I am programming this in C++, I'll post it here.

I am looking at a particle in 3D, which is being bent in the (x, y)-plane due to a force applied to it, as illustrated in the figure. The force is the bolded arrow entering from NE. The angle between the y-axis and the force is "a".

setup

The particle enters from the left with a velocity vector (v_x, v_y, v_z) and is bend around the corner. This is nicely and easily described by Newtons second law, no problems there. This is easy to solve numerically e.g. by an Euler method. This I have implemented succesfully, so far so good.

However as the figure suggests, the particle moves in a cylindrical tube of constant diameter h and I wish to find the normal distance to the wall in both the x- and z-direction (which points out of the screen) at some time t. By "normal distance" I mean that if the coordinate system rotates with the particle, then I want to know the distance from the particle to the edge of the tube along y and z (as illustrated with the 3 small arrows pointing towards the tube edge). The ultimate goal is somehow to figure out if the particle has hit the wall or not.

For the z-direction it is trivial as its axis does not change during the trajectory. However the y-direction is causing me huge problems. This is my question: Is there a way for me to find the distance to the tube edge along y during the trajectory? Note that I am doing this numerically, so I don't necessarily need an analytical expression.

Best, Niles.


Solution

  • You don't say what the shape of the tube is, but in general:

    1. If the bend in the tube is circular, then compute the distance from the particle to the center of curvature (the center of the circle) for both the inner and outer rim of the tube. Call this Dpi and Dpo (distance from particle to center of curvature, inner and outer). The distance from the center of the circle to the tube itself is constant: the radius of the circle, Ri and Ro. You can then calculate the distance of the particle from the inner and outer parts of the tube by Dpi - Ri and Dpo - Ro.

    2. If the bend in the tube is not circular, then you have to evolve a function which calculates the two radii, Ri and Ro, as function of the ANGLE of the radius, since these values will no longer be constant. Once you have this function you compute Dpi(theta) and Ri(theta) and Dpo(theta) and Ro(theta) and your distances are the differences as above.