lineEllipse

版本 1.0.0 (1.6 KB) 作者: KSSV
Get points of intersection of line and ellipse/ circle
137.0 次下载
更新时间 2018/8/24

查看许可证

This function gives points of intersection of line and ellipse. Given major axis (a), minor axos (b),
center (O(h,k)) of ellipse and two points (A(x1,y1), B(x2,y2)) lying on the stright line. This function gives two points
of intersection C1 and C2. If the line and ellipse doesn't intersect, intersections points return NaN's.


a = randperm(10,1); % some random major axis
b = randperm(10,1) ; % some random minor axis
% if a = b, we get circle
O = rand(2,1) ; % random center of ellipse

A = rand(1,2) ; B = rand(1,2) ; % Two random points for stright line

[C1,C2] = lineEllipse(a,b,O,A,B) ; % GEt intersection poins

%% plot
th = linspace(0,2*pi) ;
x = O(1)+a*cos(th) ;
y = O(2)+b*sin(th) ;

figure
plot(x,y)
hold on
plot(A(1),A(2),'.r')
plot(B(1),B(2),'.r')

plot(C1(1),C1(2),'*k')
plot(C2(1),C2(2),'*k')

L = [A ; B ; C1 ; C2] ;
plot(L(:,1),L(:,2),'g')
axis equal

引用格式

KSSV (2024). lineEllipse (https://www.mathworks.com/matlabcentral/fileexchange/68619-lineellipse), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2018a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 3-D Scene Control 的更多信息

Community Treasure Hunt

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

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