如何在MATLAB中绘制2个内部切圆? [英] how to plot 2 internal tangent circles in MATLAB?

查看:265
本文介绍了如何在MATLAB中绘制2个内部切圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从内部绘制两个相互切线的圆,然后较小的一个圆(内部圆)在另一个曲面上移动.我想在MATLAB中创建此函数,我的意思是绘制并移动圆.

i want to draw 2 circles that are tangent each other from inside, then the smaller one (internal circle) move on another surface. I want to create this function in MATLAB, I mean drawing and moving the circles.

我想在较大的表面上绕着另一个小圆圈移动.

I want to move the smaller circle around another one on the bigger one's surface.

此图显示了圆圈的位置

推荐答案

幸运的你!

正如@Neal Ehardt所说,通常您不会找到可以为您做到这一点的人,但是幸运的是,您发现有人已经在以前的项目中对此进行了整理.

As @Neal Ehardt told, normally you wouldn't find someone that will do this for you, but luckily you found someone who has already codded this in a previous project.

所以这是代码:

function [circ1,circ2]=tangent_circ(c,r1,r2,phi,n)

alpha=0:2*pi/n:2*pi;
x1=c(1)+r1*cos(alpha);
y1=c(2)+r1*sin(alpha);

paux=[c(1)+r1*cos(phi) c(2)+r1*sin(phi)];
vect=[c(1)-paux(1),c(2)-paux(2)];
vect=vect/norm(vect);
c2=paux+vect*r2;

x2=c2(1)+r2*cos(alpha);
y2=c2(2)+r2*sin(alpha);
circ1=[x1;y1];
circ2=[x2;y2];

end

此功能的输入是

  • c:所需圆[x,y]格式的中心
  • 所需圆的r1,r2半径
  • phy:内圆的位置角度(以弧度为单位)
  • n个点

输出是圆的XY坐标的2x(n + 1)个矩阵.

the outputs are 2x(n+1) matrixes of XY coords of the circles.

此代码将仅输出1个圈的设置.如果要进行圆周运动,则需要针对不同的phy值多次调用该函数.

This code will only output 1 setting of circles. If you want to have something like circular motion you will need to call the function several times for different phy values.

编辑:检查代码,我在将其放入函数时进行了一些打错. 并用phi代替phy;)

check the code, I made some typos while putting it in a function. And replaced phy with phi ;)

这篇关于如何在MATLAB中绘制2个内部切圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆