如何连接重叠的圆圈?

发布于 2024-10-07 15:24:57 字数 236 浏览 3 评论 0原文

我想在视觉上连接两个重叠的圆圈,以便

AltText

变为

alt text

我已经有部分圆的方法,但现在我需要知道每个圆的重叠角度有多大,但我不知道该怎么做。

有人有主意吗?

I want to visually join two circles that are overlapping so that

AltText

becomes

alt text

I already have methods for partial circles, but now I need to know how large the overlapping angle for earch circle is, and I don't know how to do that.

Anyone got an Idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

奢华的一滴泪 2024-10-14 15:24:57

Phi= ArcTan[ Sqrt[4 * R^2 - d^2] /d ]

太棒了!

编辑

对于两个不同的半径:

稍微简化一下:

Phi= ArcTan[Sqrt[-d^4 -(R1^2 - R2^2)^2 + 2*d^2*(R1^2 + R2^2)]/(d^2 +R1^2 -R2^2)]

编辑

如果你想要从另一个圆心看的角度,只需将最后一个方程中的R1换成R2即可。

以下是 Mathematica 中的示例实现:

f[center1_, d_, R1_, R2_] := Module[{Phi, Theta},

   Phi=  ArcTan[Sqrt[-d^4-(R1^2-R2^2)^2 + 2*d^2*(R1^2 + R2^2)]/(d^2 +R1^2 -R2^2)]

   Theta=ArcTan[Sqrt[-d^4-(R1^2-R2^2)^2 + 2*d^2*(R1^2 + R2^2)]/(d^2 -R1^2 +R2^2)]

   {Circle[{center1, 0}, R1, {2 Pi - Phi,   Phi}], 
    Circle[{d,       0}, R2, {Pi - Theta,  -Pi + Theta}]}

   ];
Graphics[f[0, 1.5, 1, 1]]

alt text

Graphics[f[0, 1.5, 1, 3/4]]  

alt text

和...

ImageMultiply[
 Binarize@FillingTransform[#], 
 ImageResize[Import@
 "http://i305.photobucket.com/albums/nn235/greeneyedgirlox/blondebabybunny.jpg", 
   ImageDimensions@#]] &@
 Rasterize@Graphics[f[0, 1.5, 1, 1], Background -> Black]

alt text

:)

Phi= ArcTan[ Sqrt[4 * R^2 - d^2] /d ]

HTH!

Edit

For two different radii:

Simplifying a little:

Phi= ArcTan[Sqrt[-d^4 -(R1^2 - R2^2)^2 + 2*d^2*(R1^2 + R2^2)]/(d^2 +R1^2 -R2^2)]

Edit

If you want the angle viewed from the other circle center, just exchange R1 by R2 in the last equation.

Here is a sample implementation in Mathematica:

f[center1_, d_, R1_, R2_] := Module[{Phi, Theta},

   Phi=  ArcTan[Sqrt[-d^4-(R1^2-R2^2)^2 + 2*d^2*(R1^2 + R2^2)]/(d^2 +R1^2 -R2^2)]

   Theta=ArcTan[Sqrt[-d^4-(R1^2-R2^2)^2 + 2*d^2*(R1^2 + R2^2)]/(d^2 -R1^2 +R2^2)]

   {Circle[{center1, 0}, R1, {2 Pi - Phi,   Phi}], 
    Circle[{d,       0}, R2, {Pi - Theta,  -Pi + Theta}]}

   ];
Graphics[f[0, 1.5, 1, 1]]

alt text

Graphics[f[0, 1.5, 1, 3/4]]  

alt text

And...

ImageMultiply[
 Binarize@FillingTransform[#], 
 ImageResize[Import@
 "http://i305.photobucket.com/albums/nn235/greeneyedgirlox/blondebabybunny.jpg", 
   ImageDimensions@#]] &@
 Rasterize@Graphics[f[0, 1.5, 1, 1], Background -> Black]

alt text

:)

花想c 2024-10-14 15:24:57

现在,即使图形是椭圆形任意数量的图形,这也将 100% 为您工作

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Pen p = new Pen(Color.Red, 2);      

        Rectangle Fig1 = new Rectangle(50, 50, 100, 50);  //dimensions of Fig1
        Rectangle Fig2 = new Rectangle(100, 50, 100, 50); //dimensions of Fig2
        . . .

        DrawFigure(e.Graphics, p, Fig1);   
        DrawFigure(e.Graphics, p, Fig2);
        . . .

        //remember to call  FillFigure after  drawing all figures.
        FillFigure(e.Graphics, p, Fig1); 
        FillFigure(e.Graphics, p, Fig2);
        . . .
    }
    private void DrawFigure(Graphics g, Pen p, Rectangle r)
    {
        g.DrawEllipse(p, r.X, r.Y, r.Width, r.Height);
    }
    private void FillFigure(Graphics g, Pen p, Rectangle r)
    {
        g.FillEllipse(new SolidBrush(this.BackColor), r.X + p.Width, r.Y + p.Width, r.Width - 2 * +p.Width, r.Height - 2 * +p.Width);      //Adjusting Color so that it will leave border and fill 
    }

Now this will work 100% for you even the figure is ellipse and any number of figures

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Pen p = new Pen(Color.Red, 2);      

        Rectangle Fig1 = new Rectangle(50, 50, 100, 50);  //dimensions of Fig1
        Rectangle Fig2 = new Rectangle(100, 50, 100, 50); //dimensions of Fig2
        . . .

        DrawFigure(e.Graphics, p, Fig1);   
        DrawFigure(e.Graphics, p, Fig2);
        . . .

        //remember to call  FillFigure after  drawing all figures.
        FillFigure(e.Graphics, p, Fig1); 
        FillFigure(e.Graphics, p, Fig2);
        . . .
    }
    private void DrawFigure(Graphics g, Pen p, Rectangle r)
    {
        g.DrawEllipse(p, r.X, r.Y, r.Width, r.Height);
    }
    private void FillFigure(Graphics g, Pen p, Rectangle r)
    {
        g.FillEllipse(new SolidBrush(this.BackColor), r.X + p.Width, r.Y + p.Width, r.Width - 2 * +p.Width, r.Height - 2 * +p.Width);      //Adjusting Color so that it will leave border and fill 
    }

alt text

深爱成瘾 2024-10-14 15:24:57

现在没有时间解决它。但我会给你解决这个问题所需的信息:

http://en。 wikipedia.org/wiki/Triangle#The_sine.2C_cosine_and_tangent_rules

在维基百科的图片中,您可以看到三角形 A、B、C。设A为左圆的圆心,B为右圆的圆心。 AC 是左圆的半径,BC 是右圆的半径。

alt text

那么点 C 将是顶部交点。 A 中的角点 α 是左圆角度的一半。b 中的角点 β 是右圆角度的一半。这些是您需要的角度,对吧?

维基百科进一步解释:“如果任何三角形的所有三边的长度已知,则可以计算三个角度。”

伪代码:

a=radius_a
b=radius_b
c=b_x - a_x
alpha=arccos((b^2 + c^2 - a^2) / (2*b*c)) //from wikipedia
left_angle=2*alpha

祝你好运:)

Don't have the time to solve it right now. But I'll give you what you need to work it out:

http://en.wikipedia.org/wiki/Triangle#The_sine.2C_cosine_and_tangent_rules

In the picture on wikipedia you see the triangle A,B,C. Let A be the center of the left circle, B the center of the right circle. And AC the radius of the left circle and BC the radius of the right circle.

alt text

Then point C would be the top intersection point. The corner in A, α, is half the angle in the left circle.The corner in b, β, half the angle in the right circle. These are the angles you need, right?

Wikipedia explains further: 'If the lengths of all three sides of any triangle are known the three angles can be calculated.'

Pseudocode:

a=radius_a
b=radius_b
c=b_x - a_x
alpha=arccos((b^2 + c^2 - a^2) / (2*b*c)) //from wikipedia
left_angle=2*alpha

Good luck :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文