Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

this is a bit more complicated than the post title suggests because I was running out of words. I suppose the full title would be: "Finding the distance between the centre of an arbitrarily rotated cylinder and a point on that cylinder which is the intersection of a ray projected from the centre of the cylinder at angles a and b, which are relative to the absolute axes."

To break it down a little:

I have a circular cylinder, which is rotated to an arbitrary orientation in 3D. I have the radius of the cylinder and I have a vector which is the vector along the cylinder's length (essentially the cylinder's orientation). The cylinder's height is infinite.

I also know the coordinates of the centre of the cylinder, let's call that point p. From p I draw a line in 3D in a direction specified by two angles, alpha and beta, which are angles of rotation in the cardinal axes of x and y (i.e. the absolute axes, and not relative to the cylinder). I would like to work out the point at which this line intersects the cylinder and also the distance between the two points.

So to break it down further:

1) I need to rotate the cylinder back to the origin, and then rotate the line by the exact same same angles to get them relative to the cylinder while the cylinder is at the origin.

2) Using this new point of reference, I need to calculate the point of intersection between the now transformed cylinder and the line made from the two transformed angles I have.

I can get x and y of this point by using rCosAlpha,rSinAlpha and I can get z by using rtanBeta (I have the adjacent - r (the radius) - and need the opposite)

And then I simply use Pythagoras' theorem to get the distance.

The problem is working this all out using these two frames of reference: absolute orientations and relative orientations. Or solving problem (1) so I don't have

Does anybody have any ideas?

share|cite|improve this question
By "centre of the cylinder", you mean some arbitrary point on the cylinder's axis? – J. M. May 8 '12 at 13:05
Yes, I'm sort of projecting the cylinder in both directions from that point so I've always been thinking of it as the centre, but you're right - if it's of infinite length then it would be an arbitrary point along its axis. – Nick Udell May 8 '12 at 13:08
One thing you could consider for rotating your cylinder to be, say, aligned to the $z$-axis would be to use spherical coordinates. If you take two points on the axis of your cylinder and set up a spherical coordinate system with respect to one of your points, you can reckon the angles you need to rotate your cylinder to a more tractable orientation. – J. M. May 8 '12 at 13:15
up vote 1 down vote accepted

The distance should be easy to determine in closed-form from $r$ (cylinder radius), $\overline{C}$ (a vector along the cylinder's center) and $\overline{P}$ (a vector representing a ray from that centerline to the point $p$).

My first stab...

$$ d = r \tan\left(\arccos{\left(\! \frac{\overline{C}\cdot\overline{P}}{|\overline{C}| |\overline{P}|} \!\right)}\right) $$

share|cite|improve this answer
Ah excellent! Thanks a lot! I'll give this a go straight away and see how it holds up. – Nick Udell May 8 '12 at 18:08
Actually, one quick question. In your example is the vector P a unit vector? All I can get for P is its unit vector (simply the direction it moves in, I don't know its length because its length is what I'm trying to find) and surely the magnitude of a unit vector is 1? – Nick Udell May 8 '12 at 18:17
You can rewrite that with unit vectors pretty easily, look up the dot product cosine identity. – Alex Hirzel May 8 '12 at 18:33
Will do, thanks – Nick Udell May 8 '12 at 18:41
Ah of course! So the solution should be d= rtan(arccos(C.P)) where r is radius, C is a unit vector along the cylinder's centre and P is a unit vector in the direction of the ray? I'll give this a go right now and see what happens, thanks! – Nick Udell May 8 '12 at 18:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.