I'm trying to find the (x, y, z) intersection of a cylinder and a plane given a cylinder aligned to the z axis and a plane rotated around the y axis like that shown below. The other parameter involved would be the angle around the z axis by which the intersection is located. This would have the inputs (R, y_rotation, z_rotation) - the cylinder would be centered at (0, 0) and projected to infinity while the plane would also cross through (0, 0, 0).

The (x, y) portion of this is simple enough - it's just projecting a point from the cylinder's center (x, y) by the angle for the distance R - for which I'm using the two formulas below (this is going into OpenSCAD, so the function definitions aren't the prettiest things.) What I'm stuck on is how to get the Z value of the intersection:

function x_cylinder_plane_intersection(z_angle, radius) = (radius * cos(z_angle));
function y_cylinder_plane_intersection(z_angle, radius) = (radius * sin(z_angle));
function z_cylinder_plane_intersection(y_angle, z_angle, radius) = ?



For any point $(x, y, z)$ on the green plane, you have $$ \tan \theta = \frac{z}{x}. $$ hence $z = x \tan(\theta)$.

Letting $t = \tan \theta$, to save a little typing, this means that your third line of code should be something like

function z_cylinder_plane_intersection(y_angle, z_angle, radius) = 
            (radius * cos(z_angle)) * tan(theta)
  • $\begingroup$ Just to make sure, is theta in the function you gave the y_angle parameter? $\endgroup$ – CoryG Jul 9 '18 at 14:14
  • $\begingroup$ It looks like theta should be y_angle per the equation you gave, but this appears to give the wrong answers. I used function z_cylinder_plane_intersection(y_angle, z_angle, radius) = (radius * sin(to_radians(z_angle))) * tan(to_radians(y_angle)); but when doing echo(z_cylinder_plane_intersection(45, 90, sqrt(2))); I get 0.000531438 where I would expect +/-1 (not sure of the +/- offhand.) $\endgroup$ – CoryG Jul 9 '18 at 14:36
  • $\begingroup$ Correction, removed the radian conversion and I get: 1.41421 or sqrt(2) from z_cylinder_plane_intersection(45, 0, sqrt(2)) - this should come out as 1 unless I'm missing something. $\endgroup$ – CoryG Jul 9 '18 at 14:45
  • $\begingroup$ Marked your answer as correct, sorry for the spam, I was using pythagora's theorem thinking of the distance to the centerpoint instead of the delta z alone. Thank you. $\endgroup$ – CoryG Jul 9 '18 at 18:22
  • $\begingroup$ My pleasure. I was using $\theta$ to denote...the thing labelled "$\Theta$" in your figure. :) $\endgroup$ – John Hughes Jul 9 '18 at 19:55

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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