# Z Intersection of Cylinder and Plane Base On Angle Around Cylinder

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

• Just to make sure, is theta in the function you gave the y_angle parameter? – CoryG Jul 9 '18 at 14:14
• 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.) – CoryG Jul 9 '18 at 14:36
• 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. – CoryG Jul 9 '18 at 14:45
• My pleasure. I was using $\theta$ to denote...the thing labelled "$\Theta$" in your figure. :) – John Hughes Jul 9 '18 at 19:55