What is the easiest way to find a cyl <-> cyl intersection?
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, thanks for looking at this,
I've been working on this problem for awhile, basically I want to find the fastest and most accurate way to find the intersection (if one exists) between two cylinders.
I've been looking at doing this using barycentric coordinates, and I can get it working quickly and efficiently using rays. When it comes to 3D, though, the mathematical formulation I have begins to slow down rapidly (~3 seconds for ~100 segments). Is there a faster way to do this, perhaps just using geometry (NURBS perhaps)?
2 件のコメント
Amit
2013 年 12 月 31 日
編集済み: Amit
2013 年 12 月 31 日
Does the cylinders have finite length? In case two cylinders intersect, there can be 2, 4 ,8 or infinte intersection point (infinite in case where two cylinders touch each other). If you are interested in only one intersection point (which verifies the cylinder do intersect), there is a simple approach using fsolve.
回答 (1 件)
Amit
2014 年 1 月 1 日
編集済み: Amit
2014 年 1 月 1 日
Lets assume both of your cylinders are of radius r1 and r2. You can represent a cylinder in cartesian coordinates (x,y,z) using parameters phi and theta (for more reference see this - http://en.wikipedia.org/wiki/Cylinder_(geometry)#About_an_arbitrary_axis) A ith cylinder can be represented as:
A_i = -x*sin(theta_i)+y*cos(theta_i)*cos(phi_i) + z*cos(theta_1)sin(phi_1)
B_i = -y*sin(phi_1) + z*cos(phi_1)
and A_i^2 + B_i^2 = ri^2
The point of intersection (x1,y1,z1) will satisfy for both cylinders.
So your function will take ([x y z]) as input (which you wanna solve) and in the function you will compute A_1, B_1, A_2 and B_2 and function output will be
F = (A_1^2+B_1^2-r1^2)^2 + (A_2^2+B_2^2-r2^2)^2 % This is what will be zero if condition satifies
You can easily solve this using fsolve. Hope this helps.
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!