0
$\begingroup$

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?

  • 0
    By "centre of the cylinder", you mean some arbitrary point on the cylinder's axis?2012-05-08
  • 0
    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.2012-05-08
  • 1
    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.2012-05-08

1 Answers 1

1

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) $$

  • 0
    Ah excellent! Thanks a lot! I'll give this a go straight away and see how it holds up.2012-05-08
  • 0
    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?2012-05-08
  • 0
    You can rewrite that with unit vectors pretty easily, look up the dot product cosine identity.2012-05-08
  • 0
    Will do, thanks2012-05-08
  • 0
    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!2012-05-08
  • 0
    No, that can't be it. I tried that with C = (0,1,0) (a vertical cylinder) and P = (1,0,0) (perpendicular to the cylinder). My value for d should be r, ergo tan(arccos(C.P)) should be coming out as 1, but it actually comes out as 1.63317787 × 10^162012-05-08
  • 0
    Ah, looking back at my math I think it should be d = r*arctan(arccos(C.P)), I'll give that a go with a few more values2012-05-08
  • 0
    I was hoping to throw you on the right track, I haven't penned the solution yet. Also Mathematica may help you to visualize this.2012-05-08
  • 0
    Yeah I think you've definitely thrown me on the right track. I've got a lot of scribbles and furious notes on a bit of paper at the moment. I've managed to build a model that doesn't yet work for an arbitrarily rotated cylinder, but I'm getting there. The current model, for reference, is: r / (cos ((pi/2) - arccos(C.P)) r/ cos(theta) giving you the length of the hypotenuse, given an angle and adjacent (r). I choose the angle as (pi/2) - arccos(C.P) as arccos(C.P) gives me the angle from the orientation the cylinder, whereas I want the angle from a vector perpendicular to the cylinder)2012-05-08
  • 0
    My problem now becomes picking the perpendicular vector as, of course, there is an infinite number of them. It has to be pointing in the same direction as the ray, with the exception of the vertical component relative to the cylinder, which must be 0 (again, relative to the cylinder).2012-05-08
  • 0
    I managed to solve my problem by finding a way of generating my rays at angles offset from the cylinder's orientation. I'll keep this question open for a bit first, though, as it's an interesting problem.2012-05-22