draw circle through two given points in plot

19 ビュー (過去 30 日間)
Josefina Ottitsch
Josefina Ottitsch 2019 年 4 月 3 日
回答済み: the cyclist 2019 年 4 月 3 日
Hello
I have the following code
close all
x = -pi:0.01:pi;
a=sin(x)
plot(x,a)
hold all
plot(1,sin(1),'o')
plot(2,sin(2),'o')
I want my program to draw a circle between the two points, given in the program, using the least squares fitting method.
How do I draw a circle between two points (without knowing radius or middlepoint) ?
thank you so much!

回答 (1 件)

the cyclist
the cyclist 2019 年 4 月 3 日
In general, there are an infinite number of circles that pass through two given points.
If you don't care which one, then one possible algorithm is to
  • for the center of the circle, find the midpoint of the line segment that connects the two points
  • for the radius, use the distance from that midpoint to one of the points
It is easy to find formulas for these two steps.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by