円筒形がいくつかある 3D 点群があります。各ポイントの (x、y、z) 座標にプログラムでアクセスできます。
3 に答える
RANSACアルゴリズムを使用できます。ウィキペディアのページには、2D ポイント クラウドとラインの例があります。3D と円柱に拡張するのは簡単です。
基本的に、円柱を完全に決定する点群から最小限のサブセットをランダムに選択し、円柱の数学的モデルを作成してから、この仮説を確認する点の数を調べます (たとえば、モデル化された円柱からいくつかのしきい値よりも遠くない)。これまでで最高のシリンダーを維持しています。あなたはそれを何度かします。
必要な円柱の場合、半径と主軸ベクトルを取得するために 4 5 ポイントが必要だと思います。次に、場合によっては、円柱の高さを決定するために別のポイントが必要になる場合があります。
5 つの点から円筒方程式を決定することを扱った記事があります: Cylinders Through Five Points: Computational Algebra and Geometry。また、付録にMathematicaコードがあり、他の記事への参照がたくさんあります。
z が範囲内かどうかを確認する[minz..maxz]
if (z > maxz || z < minz)
return false;
次に、点が中心(centerX,centerY)
と半径の円の内側にあるかどうかを確認しR
ます。
return ((x-centerX)*(x-centerX) + (y-centerY)*(y-centerY) <= R*R);
これは、シリンダーが回転していないことを前提としています
Outlining a solution: (We have used similar solution in the past, but I lost the details)
You will basically need to find center (C), axis (n) (direction cosines) and radius (r) for a cylinder.
Then for each point P, deviation (or error) from desired cylinder and a point is (calculating normal distance between point and the axis).
delta^2 = |(P -C) - (P - C) . n * n|^2 - r^2
We need to minimize the error. By using partial differentiation, and eigven vectors, we can find out values corresponding to minimum error. It is also possible to sample the points (if we know that they belong to same surface).