Point2D
介绍
Point2D类是用来生成2D的点。
案例
AddPoint (Flag=1)
AddPoint为添加点。
x=[1;2];
y=[1;5];
a=Point2D('Point Ass1');
a=AddPoint(a,x,y);
Plot(a,'grid',1,'plabel',1);
x1=-5 + (5+5)*rand(10,1);
y1=-5 + (5+5)*rand(10,1);
a=AddPoint(a,x1,y1);
Plot(a,'grid',1,'plabel',1,'group',[1;2]);
x2=[1;2;3;4;2];
y2=[2;5;3;4;5];
a=AddPoint(a,x2,y2);
Plot(a,'grid',1,'plabel',1);
a=CompressNpts(a,'all',1);
Plot(a,'grid',1,'plabel',1);
x1=ones(10,1);
y1=[0;10;20;30;40;50;60;70;80;90];
a1=Point2D('Point Ass2');
% 按角度增加点
a1=AddPoint(a1,x1,y1,'polar','deg');
Plot(a1,'grid',1,'plabel',1);
x2=ones(10,1);
y2=ones(10,1);
a2=Point2D('Point Ass3');
% 以增量的方式增加点
a2=AddPoint(a2,x2,y2,'delta',1);
Plot(a2,'grid',1,'plabel',1);
![]() | ![]() |
![]() | ![]() |
![]() | ![]() |
Calculate the distance (Flag=2)
Dist用来计算输入的坐标与点之间的距离。
a=Point2D('Point Ass1');
x1=-5 + (5+5)*rand(10,1);
y1=-5 + (5+5)*rand(10,1);
x2=-5 + (5+5)*rand(10,1);
y2=-5 + (5+5)*rand(10,1);
a=AddPoint(a,x1,y1);
a=AddPoint(a,x2,y2);
dist=Dist(2,1,a,'group',1);
disp(dist)
Delete Points (Flag=3)
DelePoint可以删除对应编号或者对应规则下的坐标点。
[X,Y]=meshgrid(0:0.1:1);
points1=[X(:),Y(:)];
a=Point2D('Point Ass1');
a=AddPoint(a, points1(:,1), points1(:,2));
Plot(a);
f=@(x,y)(x>0.5 &y>0.2 & y<0.8);
a=DeletePoint(a,1,'fun',f);
Plot(a);

Plot Point2D in paraview (Flag=4)
Plot2函数将类导出为VTK格式,并调用Paraview显示
[X,Y]=meshgrid(0:0.1:1);
points1=[X(:),Y(:)];
a=Point2D('Point Ass1');
a=AddPoint(a, points1(:,1), points1(:,2));
f=@(x,y)(x>0.5 &y>0.2 & y<0.8);
a=DeletePoint(a,1,'fun',f);
Plot(a);
Plot2(a);

Add PointData (Flag=5)
Add PointData给每个点赋值,对于一个坐标点,他有三个属性:
- 点的位置 AddPoint, 人为输入;
- 点的值 AddPointData,通常是后处理计算的结果,比如位移、应力、应变等;
- 点的向量 AddPointVector,通常为后处理的结果,代表位移、应力、应变的方向。
[X,Y]=meshgrid(0:0.1:1);
points1=[X(:),Y(:)];
a=Point2D('Point Ass1');
a=AddPoint(a, points1(:,1), points1(:,2));
f=@(x,y)(x>0.5 &y>0.2 & y<0.8);
a=DeletePoint(a,1,'fun',f);
a=AddPointData(a,a.P(:,2));
Plot(a);

Add PointVector (Flag=6)
a=Point2D('Point Ass1');
x1=-5 + (5+5)*rand(10,1);
y1=-5 + (5+5)*rand(10,1);
u=-1 + 2*rand(10,1);
v=-1 + 2*rand(10,1);
a=AddPoint(a,x1,y1);
a=AddPointVector(a,[u,v]);
a=AddPointData(a,a.P(:,2));
Plot(a,'Vector',1,'grid',1,'equal',1)
Plot2(a)
![]() | ![]() |
CheatTable
Name | Varargin | Description |
---|---|---|
AddPoint(obj,x,y) | ‘polar’,’delta’ | Add points |
AddPointData(obj,Data) | Add point data | |
AddPointVector(obj,Vec) | Add point vector | |
CompressNpts(obj) | ‘all’ | Compress point number |
DeletePoint(obj) | ‘fun’ | Delete point |
Dist(x,y,obj) | ‘group’ | Calculate distance |
GetNgpts(obj) | Get total number of point group | |
GetNpts(obj) | Get total number of points | |
GetPoint(obj,id,t) | Get point coordinate | |
Help(obj) | Open help file | |
Plot(obj) | ‘Plabel’,Grid’,’Group’,’Equal’, ‘Vector’,’VectorScale’, |
Plot Point2D object |
Plot2(obj) | Plot Point2D object in Paraview | |
VTKWrite(obj) | ‘Echo’ | Write VTK file of Point2D |
Reference
本网站基于Hexo 3-Hexz主题生成。如需转载请标注来源,如有错误请批评指正,欢迎邮件至 392176462@qq.com