Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
General Math
Calculus
Differential Equations
Topology and Analysis
Linear and Abstract Algebra
Differential Geometry
Set Theory, Logic, Probability, Statistics
MATLAB, Maple, Mathematica, LaTeX
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
General Math
Calculus
Differential Equations
Topology and Analysis
Linear and Abstract Algebra
Differential Geometry
Set Theory, Logic, Probability, Statistics
MATLAB, Maple, Mathematica, LaTeX
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Mathematics
General Math
Intersection between line and cylinder
Reply to thread
Message
[QUOTE="Joacim Jacobsen, post: 5791247, member: 625883"] This is the equations I used for the line: x=Ax*z+Bx, y=Ay*z+By (I solved for z) This is basically the .m-file that make up the intersection(sphere): function [r1v,a2v] = lens_vec(s1,r1,a1v,r0v,v1,v2,direk,mirror_skew) %Find intersection and refraction: % s1 - sphere center (z-value) % r1 - sphere radius % a1v - unit vector defining direction of ray % r0v - starting point of ray % v1 - speed of sound, material 1 % v2 - speed of sound, material 2 % direk - choose croosing, direk==0 to the right of s1, direk==1, to the % left of s1 xs = 0.0000; ys=mirror_skew; zs=s1; % center of sphere R = r1; % radius of sphere %...Define parameters for x and y coordinate of straight line (Ax,Bx), %...(Ay, By) if a1v(1) ~= 0 Ax = a1v(1)/a1v(3); else Ax = 0; end if a1v(2) ~= 0 Ay = a1v(2)/a1v(3); else Ay = 0; endBx = r0v(1)- Ax*r0v(3); By = r0v(2)- Ay*r0v(3); % Intersection straight line and sphere: a = 1 + Ax^2 + Ay^2; b = 2*(-zs + Ax*(Bx-xs) + Ay*(By-ys)); c = zs^2 + (Bx-xs)^2 + (By - ys)^2 - R^2; z1 = (-b + sqrt(b^2 - 4*a*c))/(2*a); x1 = Ax*z1+Bx; y1 = Ay*z1+By; z2 = (-b - sqrt(b^2 - 4*a*c))/(2*a); x2 = Ax*z2+Bx; y2 = Ay*z2+By; % (After this comes a section on Snell's law and refraction code) [/QUOTE]
Insert quotes…
Post reply
Forums
Mathematics
General Math
Intersection between line and cylinder
Back
Top