# Circle fit in pointcloud, stl

25 ビュー (過去 30 日間)
Patrick Brandt 2021 年 6 月 28 日

Hi,
for a project I need to fit a circle in an pointcloud in a certain hight of a 3d stl-plot. I already get the circle of the whole thing but not in the height i need to know it (-263,6365).
X=stlData.Points;
x=X(:,1);
y=X(:,2);
z=X(:,3);
x=x(:); y=y(:);
a=[x y ones(size(x))]\[-(x.^2+y.^2)];
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3))
When I set x=x(-263,6365) matlab sais it has to be positiv.
I hope you can help me.

サインインしてコメントする。

### 回答 (2 件)

Pratyush 2024 年 5 月 23 日 3:55
Hi Patrick,
To fit a circle to a subset of points from a 3D point cloud at a specific height (-263.6365) in MATLAB, follow these steps:
• Extract the x, y, and z coordinates from the point cloud data.
• Specify the desired height (z-coordinate) where you want to fit the circle. Set a tolerance level to account for the precision of your data and ensure you capture points around this height.
• Use logical indexing to filter out points that fall within the specified height range, considering the tolerance. This creates a subset of points at the desired height.
• Apply circle fitting to the filtered subset of points. This involves solving a linear system to find the circle's center (`xc`, `yc`) and radius (`R`) that best fits the points at the specified height.
• The output will be the center coordinates and radius of the circle fitted to the points around the specified height.
This method involves filtering the 3D point cloud to focus on a horizontal slice at a certain height, then applying a circle fitting algorithm to the points within that slice. Adjust the tolerance as needed based on the precision and distribution of your data.
##### 0 件のコメント-2 件の古いコメントを表示-2 件の古いコメントを非表示

サインインしてコメントする。

Matt J 2024 年 5 月 23 日 8:41
See the section "Fitting a 2D Shape to 3D Points" in the Examples tab of this FEX submission:

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by