插补算法matlab,插补算法——圆弧插补.pdf

17-6-16 上午10:16 H:\Matlab Do...\demo.m 第 1 页,共 1 页

%% 初始化

clear,clc

close all

warning off

feature jit off

%% 主程序

% R代表所插补的圆的半径

R=10;

%ThetaAround代表所要插补的角度范围

ThetaAround=[135,90;90,0;0,-45];;

% Use_SN代表所在控制的插补方向

% Use_S表示进行顺向插补 Use_N表示进行逆向插补

Use_SN 'Use_S' ;

% 通过OCT_MControl函数进行插补并返回插补信息

% Data是切削刀头的移动坐标数据

% MovePosition是切削刀头的移动方向信息

[Data,MovePosition]=OCT_MControl(ThetaAround,R,Use_SN);

%% 作图,动态演示插补过程

hold on

grid on

axis equal

ezplot(strcat( 'x^2+y^2=' ,num2str(R^2)),[-R,R]);

mycomet(Data.X,Data.Y)

17-6-16 上午10:19 H:\...\OCT_MControl.m 第 1 页,共 1 页

function [Data,MovePosition]=OCT_MControl(ThetaAround,O_R,Use_SN)

% 插补过程的总控制函数

% 对于跨过几个象限的圆弧,程序可以分段对其每个象限圆弧进行插补

Data.X=[];

Data.Y=[];

Data.Fm=[];

% 确定插补段数

for n=1:size(ThetaAround,1)

% 将半径及角度信息转换为插补的起始与终止点坐标

Position.X_FirstPosition=O_R*cosd(ThetaAround(n,1));

Position.Y_FirstPosition=O_R*sind(ThetaAround(n,1));

Position.X_EndPosition=O_R*cosd(ThetaAround(n,2));

Position.Y_EndPosition=O_R*sind(ThetaAround(n,2));

% 对每一象限的圆弧进行单独插补并返回数据

TmpData{n,1}=OCT_GetData(OCT_Function(Position,Use_SN));

% 记录移动方向信息

MovePosition{n,1}=TmpData{n,1}.MovePosition;

% 记录坐标及误差等数据信息

Data.X=[Data.X;TmpData{n,1}.X];

Data.Y=[Data.Y;TmpData{n,1}.Y];

Data.Fm=[Data.X;TmpData{n,1}.Fm];

end

17-6-16 上午10:17 H:\Matlab...\mycomet.m 第 1 页,共 3 页

function mycomet(varargin)

[ax,args,nargs] = axescheck(varargin{:});

if nargs < 1

error(message( 'MATLAB:narginchk:notEnoughInputs' ));

elseif nargs > 3

error(message( 'MATLAB:narginchk:tooManyInputs' ));

end

if nargs < 2, x = args{1}; y = x; x = 1:length(y); end

if nargs 2, [x,y] = deal(args{:}); end

if nargs < 3, p = 0.10; end

if nargs 3, [x,y,p] = deal(args{:}); end

if ~isscalar(p) || ~isreal(p) || p < 0 || p >= 1

error(message( 'MATLAB:comet:InvalidP' ));

end

ax = newplot(ax);

if ~ishold(ax)

[minx,maxx] = minmax(x);

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值