circlefit3d - fit circle to three points in 3d space

版本 1.1.0.0 (2.8 KB) 作者: Johannes Korsawe
Calculate center, radius and plane of circle that passes through three given points
3.8K 次下载
更新时间 2012/1/27

查看许可证

[center,rad,v1,v2] = circlefit3d(p1,p2,p3)

This function computes centers and radii of circles, that interpolate some given triples of points in 3d space.

The function accepts the input of matrices of trial points also, returning a matrix of corresponding centroids and a vector of corresponding radii. Corresponding points are assumed to be located in the same row in each matrix p1, p2 and p3.

Several error checks are done (collinearity, size of inputs) and return different error codes in return argument rad.

The function uses vector algebra only, is fully vectorized and should run quite fast.

Additional outputs are basis vectors v1 and v2 to describe the plane of the resulting circle.

Check:

p1=rand(4,3);p2=rand(4,3);p3=rand(4,3);
[center,rad,v1,v2] = circlefit3d(p1,p2,p3);
plot3(p1(:,1),p1(:,2),p1(:,3),'bo');hold on;plot3(p2(:,1),p2(:,2),p2(:,3),'bo');plot3(p3(:,1),p3(:,2),p3(:,3),'bo');
for i=1:361,
a = i/180*pi;
x = center(:,1)+sin(a)*rad.*v1(:,1)+cos(a)*rad.*v2(:,1);
y = center(:,2)+sin(a)*rad.*v1(:,2)+cos(a)*rad.*v2(:,2);
z = center(:,3)+sin(a)*rad.*v1(:,3)+cos(a)*rad.*v2(:,3);
plot3(x,y,z,'r.');
end
axis equal;grid on;rotate3d on;

引用格式

Johannes Korsawe (2024). circlefit3d - fit circle to three points in 3d space (https://www.mathworks.com/matlabcentral/fileexchange/34792-circlefit3d-fit-circle-to-three-points-in-3d-space), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2010b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.1.0.0

minor bugfixes

1.0.0.0