• Register
PhysicsOverflow is a next-generation academic platform for physicists and astronomers, including a community peer review system and a postgraduate-level discussion forum analogous to MathOverflow.

Welcome to PhysicsOverflow! PhysicsOverflow is an open platform for community peer review and graduate-level Physics discussion.

Please help promote PhysicsOverflow ads elsewhere if you like it.


PO is now at the Physics Department of Bielefeld University!

New printer friendly PO pages!

Migration to Bielefeld University was successful!

Please vote for this year's PhysicsOverflow ads!

Please do help out in categorising submissions. Submit a paper to PhysicsOverflow!

... see more

Tools for paper authors

Submit paper
Claim Paper Authorship

Tools for SE users

Search User
Reclaim SE Account
Request Account Merger
Nativise imported posts
Claim post (deleted users)
Import SE post

Users whose questions have been imported from Physics Stack Exchange, Theoretical Physics Stack Exchange, or any other Stack Exchange site are kindly requested to reclaim their account and not to register as a new user.

Public \(\beta\) tools

Report a bug with a feature
Request a new functionality
404 page design
Send feedback


(propose a free ad)

Site Statistics

205 submissions , 163 unreviewed
5,064 questions , 2,215 unanswered
5,347 answers , 22,741 comments
1,470 users with positive rep
818 active unimported users
More ...

  Intersection between line and cylinder

+ 0 like - 0 dislike

I am tracing a ray in Matlab and I have an expression for a "line- to sphere intersection" that works:
$a = 1 + Ax^2 + Ay^2$

$b = 2\cdot(-z_s + A_x\cdot(B_x-x_s) + A_y\cdot(B_y-y_s))$

$c = z_s^2 + (B_x-x_s)^2 + (B_y - y_s)^2 - R^2$

This is part of a code in Matlab, and works fine. It is derived from substituting 

$(x=A_x\cdot z+B_x, y=A_y\cdot z+B_y)$ (This is line in parametric, I believe.)


$((x-x_s)^2+(y-y_s)^2+(z-z_s)^2 = R^2)$  (This is the equation for a sphere, modified to find distance)

I am now trying to do the same for a cylinder, by substituting

$(x=A_x\cdot z+B_x, y=A_y\cdot z+B_y)$ (line) into: $((x-x_s)^2+(y-y_s)^2 = R^2)$ (cylinder)

Putting into quadratic formula and ending up with:

$a = A_x^2+A_y^2$;

$b = 2\cdot A_x\cdot B_x - 2\cdot A_x\cdot x_s + 2\cdot A_y\cdot B_y - 2\cdot A_y\cdot y_s;$

$c = -2\cdot B_x\cdot x_s - 2\cdot B_y\cdot y_s + B_x^2 + B_y^2 + x_s^2+y_s^2 - R^2;$

This doesn't seem to work. Can anyone tell me if something seems off with the math or logic?
Any comments at all would be greatly appreciated.

What I'm asking is this: 

Is there a way to describe a line- cylinder intersection, using a,b,c, like I have for a line- sphere intersection(below)?

$a = 1 + Ax^2 + Ay^2$

$b = 2\cdot(-z_s + A_x\cdot(B_x-x_s) + A_y\cdot(B_y-y_s))$

$c = z_s^2 + (B_x-x_s)^2 + (B_y - y_s)^2 - R^2$

Closed by author request
asked Jun 27, 2017 in Closed Questions by Aldo (0 points) [ revision history ]
recategorized Jul 13, 2017 by dimension10

I can promise that nobody will read your question until you Latex it. 

Try math.stackexchange for questions like these!

not graduate+ level. Users with 500+ reputation may vote here to get it closed.

user contributions licensed under cc by-sa 3.0 with attribution required

Your rights