Finding points of intersection between Curve and sides of a square

1 回表示 (過去 30 日間)
Siddharth Behal
Siddharth Behal 2021 年 12 月 11 日
回答済み: Matt J 2021 年 12 月 11 日
clc
clear all
close all
S = 2;
a = 0.1
a = 0.1000
b = 0.2
b = 0.2000
p_crd = [0,S]
p_crd = 1×2
0 2
p_x = [((1+S)/2)+a S+0.5 S+0.5 ((1+S)/2) ((1+S)/2)];
p_y = [(1+S)/2 (1+S)/2 S+0.5 S+0.5 ((S+1)/2)+b];
plate = plot(p_x,p_y);
n =15;
axis([0,3,0,3]);
hold on
theta = linspace(0,pi/2,1000);
h = 1.5;
k = 1.5;
del = linspace(0,((S)/sqrt(2))-0.25,n)
del = 1×15
0 0.0832 0.1663 0.2495 0.3326 0.4158 0.4989 0.5821 0.6653 0.7484 0.8316 0.9147 0.9979 1.0811 1.1642
for i = 1:n
hold on
a2 = a+del(i);
b2 = b+del(i);
x{i} = h + a2*cos(theta);
y{i} = k + b2*sin(theta);
plot(x{i},y{i});
end
axis square
As you can see, I want the ellipses to be restricted within the sides of square and know their intersecting points. I tried the inpolygon function but it resulted in lines within the square but not upto the side of the square plate. If someone can please help, it would be highly appreciated.

回答 (1 件)

Matt J
Matt J 2021 年 12 月 11 日
If you make the appropriate change of coordinates, your ellipses will become circles and your square will become a more general polygon. You can then use the methods discussed in this similar thread.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by