Line
介绍
Line类是用来生成3D的曲线,基于Nurb tool$^{[1]}$,生成3D曲线。
案例
Add different curves (Flag=1)
%% AddLine
a=Point('Point Ass1');
a=AddPoint(a,[0;5],[0;4],[0;2]);
b=Line('Line Ass1');
b=AddLine(b,a,1);
Plot(b,'clabel',1,'styles',{'-'});
%% AddCurve
P = [0.5 1.5 4.5 3.0 7.5 6.0 8.5;
3.0 5.5 5.5 1.5 1.5 4.0 4.5;
0.0 0.0 0.0 0.0 0.0 0.0 0.0];
a=AddPoint(a,P(1,:)',P(2,:)',P(3,:)');
b=AddCurve(b,a,2);
Plot(b,'clabel',1,'styles',{'-'});
%% AddCircle
a=AddPoint(a,0,0,5);
b=AddCircle(b,2.5,a,3);
b=AddCircle(b,3,a,3,'rot',[45,45,45]);
Plot(b,'clabel',1,'styles',{'-'});
%% AddEllipse
b=AddEllipse(b,6,3,a,3,'rot',[0,-90,0],'sang',-90,'ang',180);
Plot(b,'clabel',1,'styles',{'-'});
%% AddNurb
coefs = [0.0 7.5 15.0 25.0 35.0 30.0 27.5 30.0;
0.0 2.5 0.0 -5.0 5.0 15.0 22.5 30.0;
0 0 0 0 0 0 0 0]';
knots = [0.0 0.0 0.0 1/6 1/3 1/2 2/3 5/6 1.0 1.0 1.0];
b=AddNurb(b,coefs,knots);
Plot(b,'clabel',1,'styles',{'-'});

Insert new knots (Flag=2)
Nurb曲线插入新的控制点。
coefs = [0.5 1.5 4.5 3.0 7.5 6.0 8.5;
3.0 5.5 5.5 1.5 1.5 4.0 4.5;
0.0 0.0 0.0 0.0 0.0 0.0 0.0]';
knots=[0 0 0 1/10 2/5 3/5 4/5 1 1 1];
b=Line('Line Ass1');
b=AddNurb(b,coefs,knots);
Plot(b,'coefs',1);
b=InsertKnots(b,1,[0.125 0.375 0.625 0.875]);
Plot(b,'coefs',1);
![]() | ![]() |
Move curve (Flag=3)
移动曲线。
coefs = [0.5 1.5 4.5 3.0 7.5 6.0 8.5;
3.0 5.5 5.5 1.5 1.5 4.0 4.5;
0.0 0.0 0.0 0.0 0.0 0.0 0.0]';
knots=[0 0 0 1/10 2/5 3/5 4/5 1 1 1];
b=Line('Line Ass1');
b=AddNurb(b,coefs,knots);
b=Move(b,1,[0,0,5],'new',1);
Plot(b);

Rotate curve (Flag=4)
旋转曲线。
coefs = [0.5 1.5 4.5 3.0 7.5 6.0 8.5;
3.0 5.5 5.5 1.5 1.5 4.0 4.5;
0.0 0.0 0.0 0.0 0.0 0.0 0.0]';
knots=[0 0 0 1/10 2/5 3/5 4/5 1 1 1];
b=Line('Line Ass1');
b=AddNurb(b,coefs,knots);
b=Move(b,1,[0,0,5],'new',1);
b=Rotate(b,2,[0,0,90]);
Plot(b);

Scale curve (Flag=5)
缩放曲线。
coefs = [0.5 1.5 4.5 3.0 7.5 6.0 8.5;
3.0 5.5 5.5 1.5 1.5 4.0 4.5;
0.0 0.0 0.0 0.0 0.0 0.0 0.0]';
knots=[0 0 0 1/10 2/5 3/5 4/5 1 1 1];
b=Line('Line Ass1');
b=AddNurb(b,coefs,knots);
b=Move(b,1,[0,0,5],'new',1);
b=Scale(b,2,[0.5,0.5,1]);
Plot(b);

CheatTable
Name | Varargin | Description |
---|---|---|
AddCircle(obj,r,Point2D,P) | ‘sang’,’ang’,’seg’,’rot’ | Add circle |
AddCurve(obj,Point2D,P) | Add curve | |
AddEllipse( obj, a, b,Point2D,P) | ‘rot’,’sang’,’ang’,’seg’ | Add ellipse |
AddLine(obj,Point2D,P) | Add straight line | |
AddNurb(obj,coefs,knots) | ‘seg’ | Add nurb curve |
GetNcrv(obj) | Get total number of curve | |
InsertKnots(obj,LineNo,knots) | Insert knots | |
Help(obj) | Open help file | |
Move(obj,num,dis) | ‘new’ | Move curve |
Plot(obj) | ‘grid’,’axe’,’clabel’,’styles’, ‘equal’,’crv’,’map’,’color’, ‘base_size’,’xlim’,’ylim’ |
Plot line object |
Plot2(obj) | Plot line on paraview | |
Rotate(obj,num,rot) | ‘new’, ‘ori’ | Rotate curve |
Scale(obj,num,factor) | ‘new’, ‘ori’ | Sacale curve |
VTKWrite(obj) | Write VTK file of line |
参考文献
[1] https://ww2.mathworks.cn/matlabcentral/fileexchange/26390-nurbs-toolbox-by-d-m-spink?s_tid=srchtitle
本网站基于Hexo 3-Hexz主题生成。如需转载请标注来源,如有错误请批评指正,欢迎邮件至 392176462@qq.com