// 毕业设计Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "毕业设计.h"
#include "毕业设计Dlg.h"
#include
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CAboutDlg dialog used for App About
#define Time 300 //插补延迟的时间
#define Minnum 0.0000001//精度补偿
int ZuoBiaobl = 1;//为了存取当前坐标倍率
int sgn_r;//判断左右刀补
int ShunNi;//判断顺逆
int ShunNi2;//圆弧接圆弧第二段顺逆判断
int jianli = 0;//刀补建立
int jinxing = 0;//刀补进行
int chexiao = 0;//刀补撤消
int yuanxin = 1;//计算出两个圆心的取舍
int yuanxin2 = 1;//圆弧接圆弧第二段圆心的取舍
double Xs[50] = { 0 };//存转接点横坐标
double Ys[50] = { 0 };//存转接点纵坐标
int ZhixianOrYuanhu[100] = { 0 };//存相邻两个转接点之间连接方式(直线或是圆弧,直线记为1,圆弧记为-1)
static int i = 0;//转接点序号
static int j = 0;//转接连接方式序号
//(转接连接方式序号比转接点序号多一个,不过为了方面插补,要在第一个转接点之前加一个进刀点,在最后一个转接点后面加一个退刀点)
// 这导致转接点序号比转接连接方式序号多一个
double Xyuanhu[50] = { 0 };//存转接时计算出来的圆心横坐标
double Yyuanhu[50] = { 0 };//存转接时计算出来的圆心纵坐标
double Ryuanhu[50] = { 0 };//存转接时计算出来的圆的半径,顺圆记为正,逆圆记为负
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
r1 = 0.0;
r2 = 0.0;
x0 = 0.0;
x1 = 0.0;
x2 = 0.0;
y0 = 0.0;
y1 = 0.0;
y2 = 0.0;
r = 0.0;
Delta = 0.0;
N = 0;
step = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDC_COMBO, m_ComboBox);
DDX_Text(pDX, IDC_R1, r1);
DDX_Text(pDX, IDC_R2, r2);
DDX_Text(pDX, IDC_X0, x0);
DDX_Text(pDX, IDC_X1, x1);
DDX_Text(pDX, IDC_X2, x2);
DDX_Text(pDX, IDC_Y0, y0);
DDX_Text(pDX, IDC_Y1, y1);
DDX_Text(pDX, IDC_Y2, y2);
DDX_Text(pDX, IDC_Daojubanjing, r);
DDX_Text(pDX, IDC_Delta, Delta);
DDX_Text(pDX, IDC_JiCunQi, N);
DDX_Text(pDX, IDC_BuChang, step);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_Jianlizuobiaoxi, OnZuobiaoxi)
ON_CBN_SELCHANGE(IDC_COMBO, OnSelchangeCombo)
ON_BN_CLICKED(IDC_Zuodaobu, OnZuodaobu)
ON_BN_CLICKED(IDC_Youdaobu, OnYoudaobu)
ON_BN_CLICKED(IDC_Daojubanjingbuchang, OnDaojubanjingbuchang)
ON_BN_CLICKED(IDC_Shunyuan, OnShunyuan)
ON_BN_CLICKED(IDC_Niyuan, OnNiyuan)
ON_BN_CLICKED(IDC_Zhaoyuanxin, OnZhaoyuanxin)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_Daobujianli, OnDaobujianli)
ON_BN_CLICKED(IDC_Daobujinxing, OnDaobujinxing)
ON_BN_CLICKED(IDC_Daobuchexiao, OnDaobuchexiao)
ON_BN_CLICKED(IDC_Shunyuan2, OnShunyuan2)
ON_BN_CLICKED(IDC_Niyuan2, OnNiyuan2)
ON_BN_CLICKED(IDC_Zhaoyuanxin2, OnZhaoyuanxin2)
ON_BN_CLICKED(IDC_Zhudianbijiaofa, OnZhudianbijiaofa)
ON_BN_CLICKED(IDC_ShuZiJiFenFa, OnShuZiJiFenFa)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CMyDlg message handlers
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
pWnd = GetDlgItem(IDC_MYSTATIC); //指向画坐标的区域
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//CDialog::OnPaint();
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
CDC dcMem; //定义一个工具箱(设备上下文)
dcMem.CreateCompatibleDC(&dc); //建立关联DC
CBitmap bmpBackground; //位图对象
bmpBackground.LoadBitmap(IDB_BITMAP2); //IDB_BITMAP2是你自己的图对应的ID
BITMAP bitmap;
bmpBackground.GetBitmap(&bitmap); //建立绑定关系
CBitmap *pbmpOld = dcMem.SelectObject(&bmpBackground); //保存原有CDC对象,并选入新CDC对象入DC
dc.SetStretchBltMode(COLORONCOLOR);//防止bmp图片失真
dc.StretchBlt(0, 0, rect.Width(), rect.Height(), &dcMem, 0, 0,
bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
}
}
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
/*if(pWnd->GetDlgCtrlID()==IDC_STATIC)//如果是静态编辑框
{
pDC->SetTextColor(RGB(0,0,0));//修改字体的颜色
pDC->SetBkMode(TRANSPARENT);//把字体的背景变成透明的
CFont font;
font.CreatePointFont(100,"黑体");
pDC->SelectObject(&font);//设置字体
return HBRUSH(GetStockObject(HOLLOW_BRUSH));//返回背景色
}*/
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT); //设置背景透明
pDC->SetTextColor(RGB(0, 0, 0)); //设置字体为黑色
return HBRUSH(GetStockObject(HOLLOW_BRUSH));//返回背景色
}
return hbr;
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR)m_hIcon;
}
/********坐标系倍率选择*************/
void CMyDlg::OnSelchangeCombo()
{
// TODO: Add your control notification handler code here
int nChoice = m_ComboBox.GetCurSel();//获得当前选项的索引
switch (nChoice)
{
case(0):
ZuoBiaobl = 1;
break;
case 1:
ZuoBiaobl = 10;
break;
case 2:
ZuoBiaobl = 100;
break;
}
}
/************画坐标系**************/
void CMyDlg::OnZuobiaoxi()
{
// TODO: Add your control notification handler code here
CPaintDC dc(this);
CString str;
int i;
pWnd->Invalidate();
pWnd->UpdateWindow();//更新窗口
CDC *pDC = pWnd->GetDC();//获取当前窗口的类对象指针
pDC->Rectangle(0, 0, 800, 700);//画一个矩形框
CPen *pPenRed = new CPen();//创建画笔对象
pPenRed->CreatePen(PS_SOLID, 3, RGB(0, 0, 0));//黑色画笔
CPen *pPen = NULL;
CGdiObject *pOldPen = pDC->SelectObject(pPenRed);
pDC->SetMapMode(MM_ANISOTROPIC);// 设置映射模式
pDC->SetViewportOrg(800 / 2, 700 / 2);//映射后坐标系原点
pDC->SetViewportExt(800, 700);//映射后坐标系终点
pDC->SetWindowOrg(0, 0);//原来坐标系的原点
pDC->SetWindowExt(1000, -1000);//原来坐标系的终点,但y轴方向取反
pDC->MoveTo(0, -450);
pDC->LineTo(0, 450);
pDC->LineTo(-6, 445);
pDC->MoveTo(0, 450);
pDC->LineTo(6, 445);
pDC->MoveTo(-450, 0);
pDC->LineTo(450, 0);
pDC->LineTo(445, 6);
pDC->MoveTo(450, 0);
pDC->LineTo(445, -6);
pDC->MoveTo(0, 0);
//写x轴正刻度
for (i = 0;i <= 10;i++)
{
str.Format("%d", i*ZuoBiaobl);
pDC->TextOut(40.0 * i - 4, -1, str); //-4,-1是为了是刻度和数字上下对齐
//绘制x轴刻度
pDC->MoveTo(40.0 * i, 0);
pDC->LineTo(40.0 * i, 5); //坐标轴上刻度的高度为5
}
//写x轴负刻度
for (i = -1;i >= -10;i--)
{
str.Format("%d", i*ZuoBiaobl);
pDC->TextOut(40.0 * i - 8, -1, str);
//绘制x轴刻度
pDC->MoveTo(40.0 * i, 0);
pDC->LineTo(40.0 * i, 5);
}
//写y轴正刻度
for (i = 1;i <= 10;i++)
{
str.Format("%d", i*ZuoBiaobl);
pDC->TextOut(-30, 40.0 * i + 8, str);
//绘制y轴刻度
pDC->MoveTo(0, 40.0 * i);
pDC->LineTo(-5, 40.0 * i);
}
//写y轴负刻度
for (i = -1;i >= -10;i--)
{
str.Format("%d", i*ZuoBiaobl);
pDC->TextOut(-35, 40.0 * i + 8, str);
//绘制y轴刻度
pDC->MoveTo(0, 40.0 * i);
pDC->LineTo(-5, 40.0 * i);
}
//恢复画笔
pDC->SelectObject(pOldPen);
delete pPenRed;
if (pPen != NULL)
delete pPen;
ReleaseDC(pDC);
}
/************设定为左刀补**************/
void CMyDlg::OnZuodaobu()
{
// TODO: Add your control notification handler code here
sgn_r = 1;
CWnd *pWndButn;
pWndButn = GetDlgItem(IDC_Daobujianli);
pWndButn->EnableWindow();
pWndButn = GetDlgItem(IDC_Daobujinxing);
pWndButn->EnableWindow();
pWndButn = GetDlgItem(IDC_Daobuchexiao);
pWndButn->EnableWindow();
}
/************设定为右刀补**************/
void CMyDlg::OnYoudaobu()
{
// TODO: Add your control notification handler code here
sgn_r = -1;
CWnd *pWndButn;
pWndButn = GetDlgItem(IDC_Daobujianli);
pWndButn->EnableWindow();
pWndButn = GetDlgItem(IDC_Daobujinxing);
pWndButn->EnableWindow();
pWndButn = GetDlgItem(IDC_Daobuchexiao);
pWndButn->EnableWindow();
}
void CMyDlg::OnShunyuan() //顺圆
{
// TODO: Add your control notification handler code here
if (ShunNi == 1)
{
((CButton*)GetDlgItem(IDC_Shunyuan))->SetCheck(0);
}
else
ShunNi = 1;
}
void CMyDlg::OnNiyuan() //逆圆
{
// TODO: Add your control notification handler code here
if (ShunNi == -1)
{
((CButton*)GetDlgItem(IDC_Niyuan))->SetCheck(0);
}
else
ShunNi = -1;
}
void CMyDlg::OnShunyuan2() //圆弧接圆弧第二段顺圆
{
// TODO: Add your control notification handler code here
if (ShunNi2 == 1)
{
((CButton*)GetDlgItem(IDC_Shunyuan2))->SetCheck(0);
}
else
ShunNi2 = 1;
}
void CMyDlg::OnNiyuan2() //圆弧接圆弧第二段逆圆
{
// TODO: Add your control notification handler code here
if (ShunNi2 == -1)
{
((CButton*)GetDlgItem(IDC_Niyuan2))->SetCheck(0);
}
else
ShunNi2 = -1;
}
void CMyDlg::OnDaobujianli() //刀补建立
{
// TODO: Add your control notification handler code here
jianli = 1;
jinxing = 0;
chexiao = 0;
}
void CMyDlg::OnDaobujinxing() //刀补进行
{
// TODO: Add your control notification handler code here
jinxing = 1;
jianli = 0;
chexiao = 0;
}
void CMyDlg::OnDaobuchexiao() //刀补撤消
{
// TODO: Add your control notification handler code here
chexiao = 1;
jianli = 0;
jinxing = 0;
}
/************创建红色画笔**************/
void Cjhshb(CDC *pDC)
{
CPen *pPenRed = new CPen();//创建画笔对象
pPenRed->CreatePen(PS_SOLID, 3, RGB(255, 0, 0));//红色画笔
CPen *pPen = NULL;
CGdiObject *pOldPen = pDC->SelectObject(pPenRed);
}
/************创建绿色画笔**************/
void Cjlshb(CDC *pDC)
{
CPen *pPenRed = new CPen();//创建画笔对象
pPenRed->CreatePen(PS_SOLID, 3, RGB(0, 255, 0));//绿色画笔
CPen *pPen = NULL;
CGdiObject *pOldPen = pDC->SelectObject(pPenRed);
}
void CMyDlg::OnZhaoyuanxin()//两个圆心的取舍
{
// TODO: Add your control notification handler code here
if (yuanxin == -1)
{
((CButton*)GetDlgItem(IDC_Zhaoyuanxin))->SetCheck(0);
yuanxin = 1;
}
else
yuanxin = -1;
}
void CMyDlg::OnZhaoyuanxin2()
{
// TODO: Add your control notification handler code here
if (yuanxin2 == -1)
{
((CButton*)GetDlgItem(IDC_Zhaoyuanxin2))->SetCheck(0);
yuanxin2 = 1;
}
else
yuanxin2 = -1;
}
int XiaoChuWuCha(double &x)//消除double型参数误差问题
{
if (fabs(x - int(x)) < Minnum)
x = int(x);
if (fabs(x - (int(x) + 1)) < Minnum)
x = int(x) + 1;
return x;
}
/************由已知圆弧两点和半径求圆心坐标**************/
void YuanXin(double m1, double n1, double m2, double n2, double R, double &x, double &y)
{
int flag1 = (yuanxin < 0) ? -1 : 1;
int flag2 = (ShunNi > 0) ? 1 : -1;
double dx = m2 - m1, dy = n2 - n1;
double length = sqrt(dx*dx + dy*dy);
dx = dx / length;
dy = dy / length;
length = sqrt(R*R - length*length / 4);
x = (m2 + m1) / 2 + flag1*flag2*dy*length;
y = (n2 + n1) / 2 - flag1*flag2*dx*length;
XiaoChuWuCha(x);
XiaoChuWuCha(y);
}
void YuanXin2(double m1, double n1, double m2, double n2, double R, double &x, double &y)//圆弧接圆弧第二段圆心计算
{
int flag1 = (yuanxin2 < 0) ? -1 : 1;
int flag2 = (ShunNi2 > 0) ? 1 : -1;
double dx = m2 - m1, dy = n2 - n1;
double length = sqrt(dx*dx + dy*dy);
dx = dx / length;
dy = dy / length;
length = sqrt(R*R - length*length / 4);
x = (m2 + m1) / 2 + flag1*flag2*dy*length;
y = (n2 + n1) / 2 - flag1*flag2*dx*length;
XiaoChuWuCha(x);
XiaoChuWuCha(y);
}
int SiSheWuRu(double &x)//小数取整函数
{
if (x - int(x) < 0.5)
{
x = int(x);
}
else
x = int(x) + 1;
return x;
}
int sgn(double d)//符号函数,正为1,负为-1,0为0
{
if (d < 0)
return -1;
else if (d == 0)
return 0;
else
return 1;
}
/************刀具半径补偿**************/
void CMyDlg::OnDaojubanjingbuchang()
{
// TODO: Add your control notification handler code here
UpdateData(true);
//pWnd = GetDlgItem(IDC_MYSTATIC);
CPaintDC dc(this);
//CString str;
CDC *pDC = pWnd->GetDC();//获取控件指针
CPen *pPenRed = new CPen();//创建画笔对象
pPenRed->CreatePen(PS_SOLID, 3, RGB(0, 0, 255));//蓝色画笔
CPen *pPen = NULL;
CGdiObject *pOldPen = pDC->SelectObject(pPenRed);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetViewportOrg(800 / 2, 700 / 2);
pDC->SetViewportExt(800, 700);
pDC->SetWindowOrg(0, 0);
pDC->SetWindowExt(1000, -1000);
x0 = x0 / ZuoBiaobl;//使坐标对应选择的坐标倍率
y0 = y0 / ZuoBiaobl;
x1 = x1 / ZuoBiaobl;
y1 = y1 / ZuoBiaobl;
x2 = x2 / ZuoBiaobl;
y2 = y2 / ZuoBiaobl;
r1 = r1 / ZuoBiaobl;
r2 = r2 / ZuoBiaobl;
r = r / ZuoBiaobl;
double d1, d2;
d1 = sqrt((x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0));
d2 = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
double Xl1, Yl1, Xl2, Yl2;
Xl1 = (x1 - x0) / d1;
Yl1 = (y1 - y0) / d1;
Xl2 = (x2 - x1) / d2;
Yl2 = (y2 - y1) / d2;
double Rx, Ry;//直线接圆弧圆心坐标
YuanXin(x1, y1, x2, y2, r2, Rx, Ry);
double I, J;
I = Rx - x1;
J = Ry - y1;
double R = ShunNi*sqrt(I*I + J*J);
double Xl3 = -J / R;
double Yl3 = I / R;
double f = sqrt((R + sgn_r*r)*(R + sgn_r*r) - (Xl1*J - Yl1*I - sgn_r*r)*(Xl1*J - Yl1*I - sgn_r*r));
double Rx1, Ry1;//圆弧接直线圆心坐标
YuanXin(x0, y0, x1, y1, r1, Rx1, Ry1);
double I1, J1;
I1 = Rx1 - x0;
J1 = Ry1 - y0;
double R1 = ShunNi*sqrt(I1*I1 + J1*J1);
double R10;
if ((sgn_r == 1 && ShunNi == 1) || (sgn_r == -1 && ShunNi == -1))//左刀补顺时针或右刀补逆时针
{
R10 = sqrt(I1*I1 + J1*J1) + r;//为了由两个转接点计算刀具轨迹半径,要正值
}
else if ((sgn_r == 1 && ShunNi == -1) || (sgn_r == -1 && ShunNi == 1))//左刀补逆时针或右刀补顺时针
{
R10 = sqrt(I1*I1 + J1*J1) - r;
}
double X01, Y01;
X01 = x0 + I1 - x1;
Y01 = y0 + J1 - y1;
double Xl4, Yl4;
Xl4 = -Y01 / R1;
Yl4 = X01 / R1;
double f1 = sqrt((R1 + sgn_r*r)*(R1 + sgn_r*r) - (Xl2*Y01 - Yl2*X01 - sgn_r*r)*(Xl2*Y01 - Yl2*X01 - sgn_r*r));
double Rx2, Ry2, Rx3, Ry3;//圆弧接圆弧圆心坐标
YuanXin(x0, y0, x1, y1, r1, Rx2, Ry2);
YuanXin2(x1, y1, x2, y2, r2, Rx3, Ry3);
double I2, J2, I3, J3;
if (x0 == x1)
{
I2 = 0;
J2 = sgn(Ry2 - y0)*r1;
}
else
{
I2 = Rx2 - x0;
J2 = Ry2 - y0;
}
if (x1 == x2)
{
I3 = 0;
J3 = sgn(Ry3 - y1)*r2;
}
else
{
I3 = Rx3 - x1;
J3 = Ry3 - y1;
}
double R2 = ShunNi*sqrt(I2*I2 + J2*J2);
double R3 = ShunNi2*sqrt(I3*I3 + J3*J3);
double R20, R30;
if (ShunNi == ShunNi2 && ShunNi==-1)//两段圆弧都是逆时针 左刀补减,右刀补加
{
R20 = sqrt(I2*I2 + J2*J2) - sgn_r*r;
R30 = sqrt(I3*I3 + J3*J3) - sgn_r*r;
}
else if (ShunNi == ShunNi2 && ShunNi == 1)//两段圆弧都是顺时针 左刀补加,右刀补减
{
R20 = sqrt(I2*I2 + J2*J2) + sgn_r*r;
R30 = sqrt(I3*I3 + J3*J3) + sgn_r*r;
}
else if (ShunNi != ShunNi2)
{
if (ShunNi == 1)
{
R20 = sqrt(I2*I2 + J2*J2) + sgn_r*r;
R30 = sqrt(I3*I3 + J3*J3) - sgn_r*r;
}
else if (ShunNi == -1)
{
R20 = sqrt(I2*I2 + J2*J2) - sgn_r*r;
R30 = sqrt(I3*I3 + J3*J3) + sgn_r*r;
}
}
double X02, Y02, X03, Y03;
X02 = x0 + I2 - x1;
Y02 = y0 + J2 - y1;
X03 = I3;
Y03 = J3;
double Xl5, Yl5, Xl6, Yl6;
Xl5 = -Y02 / R2;
Yl5 = X02 / R2;
Xl6 = -Y03 / R3;
Yl6 = X03 / R3;
double d3 = sqrt((X03 - X02)*(X03 - X02) + (Y03 - Y02)*(Y03 - Y02));
double d4 = sgn_r*r*(R2 - R3) / d3;
double XL = (Y03 - Y02) / d3;
double YL = -(X03 - X02) / d3;
double f2 = sqrt((R3 + sgn_r*r)*(R3 + sgn_r*r) - (XL*Y03 - YL*X03 - d4)*(XL*Y03 - YL*X03 - d4));
double temp1, temp2;//直线接直线转接类型判断条件
temp1 = sgn(sgn_r*r)*(Yl2*Xl1 - Xl2*Yl1);
temp2 = Yl2*Yl1 + Xl2*Xl1;
double temp3, temp4;//直线接圆弧转接类型判断条件
temp3 = sgn(sgn_r*r)*(Yl3*Xl1 - Xl3*Yl1);
temp4 = Yl3*Yl1 + Xl3*Xl1;
if ((temp3 > double(-0.008) && temp3 <= 0) || (temp3 < double(0.008) && temp3 >= 0))//圆弧起点终点的横坐标相同
{
temp3 = 0;
}
double temp5, temp6;//圆弧接直线转接类型判断条件
temp5 = sgn(sgn_r*r)*(Yl2*Xl4 - Xl2*Yl4);
temp6 = Yl2*Yl4 + Xl2*Xl4;
if ((temp5 > double(-0.008) && temp5 <= 0) || (temp5 < double(0.008) && temp5 >= 0))//圆弧起点终点的横坐标相同
{
temp5 = 0;
}
double temp7, temp8;//圆弧接圆弧转接类型判断条件
temp7 = sgn(sgn_r*r)*(Yl6*Xl5 - Xl6*Yl5);
temp8 = Yl6*Yl5 + Xl6*Xl5;
/************直线接直线**************/
if (r1 == 0 && r2 == 0)//直线接直线判断条件
{
//####################缩短型###################################
if (temp1 > 0)//转接角范围为(180,360)
{
if (jianli == 1)//缩短型刀补建立
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (jinxing == 1)//缩短型刀补进行
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + ((Xl2 - Xl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
Ys[i] = y1 + ((Yl2 - Yl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (chexiao == 1)//缩短型刀补撤销
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
//刀补撤销时i就不用再加1了
}
}
if (jianli == 1 && temp1 == 0 && temp2 < 0)//建立时转接角为0度
{
MessageBox("直线接直线刀补建立时,转接角α=0会导致刀具干涉,请重新输入", "警告", NULL);
}
if (jianli == 1 && temp1 == 0 && temp2 > 0)//建立时转接角为180度
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
if (jinxing == 1 && temp1 == 0 && temp2 < 0)//进行时转接角为0度
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
if (jinxing == 1 && temp1 == 0 && temp2 > 0)//进行时转接角为180度
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
if (chexiao == 1 && temp1 == 0 && temp2 < 0)//撤消时转接角为0度
{
MessageBox("直线接直线刀补撤消时,转接角α=0会导致刀具干涉,请重新输入", "警告", NULL);
}
if (chexiao == 1 && temp1 == 0 && temp2 > 0)//撤消时转接角为180度
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
//pDC->LineTo(40.0 * x1, 40.0 * y1);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
}
//########################伸长型###############################
else if (temp1 < 0 && temp2 >= 0)//转接角范围为[90,180)
{
if (jianli == 1)//伸长型刀补建立
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 + ((Xl2 - Xl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
Ys[i] = y1 + ((Yl2 - Yl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (jinxing == 1)//伸长型刀补进行
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + ((Xl2 - Xl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
Ys[i] = y1 + ((Yl2 - Yl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (chexiao == 1)//伸长型刀补撤销
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
//pDC->LineTo(40.0 * x1, 40.0 * y1);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + ((Xl2 - Xl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
Ys[i] = y1 + ((Yl2 - Yl1)*sgn_r*r) / (Xl1*Yl2 - Xl2*Yl1);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
}
}
//########################插入型###############################
else if (temp1 < 0 && temp2 < 0)//转接角范围为(0,90)
{
if (jianli == 1)//插入型刀补建立
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (jinxing == 1)//插入型刀补进行
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (chexiao == 1)//插入型刀补撤销
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
//pDC->LineTo(40.0 * x1, 40.0 * y1);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
//刀补撤销时i就不用再加1了
}
}
}
/************直线接圆弧**************/
if (r1 == 0 && r2 != 0)//直线接圆弧判断条件
{
//####################缩短型###################################
if (chexiao == 1)
{
MessageBox("一般情况下,直线接圆弧转接时,圆弧不能作为退刀编程轨迹,请重新输入", "警告", NULL);
}
if (temp3 > 0)//转接角范围为(180,360)
{
if (jianli == 1)//缩短型刀补建立
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (jinxing == 1)//缩短型刀补进行
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + Xl1*(Xl1*I + Yl1*J) - sgn_r*r*Yl1 - sgn(Xl1*I + Yl1*J)*Xl1*f;
Ys[i] = y1 + Yl1*(Xl1*I + Yl1*J) + sgn_r*r*Xl1 - sgn(Xl1*I + Yl1*J)*Yl1*f;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
if (jianli == 1 && temp3 == 0 && temp4 < 0)//建立时转接角为0度
{
MessageBox("直线接圆弧刀补建立时,转接角α=0会导致刀具干涉,请重新输入", "警告", NULL);
}
if (jianli == 1 && temp3 == 0 && temp4 > 0)//建立时转接角为180度
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
if (jinxing == 1 && temp3 == 0 && temp4 < 0)//进行时转接角为0度
{
if ((sgn_r == 1 && ShunNi == 1) || (sgn_r == -1 && ShunNi == -1))//左刀补顺时针或右刀补逆时针
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + Xl1*(Xl1*I + Yl1*J) - sgn_r*r*Yl1 - Xl1*f;
Ys[i] = y1 + Yl1*(Xl1*I + Yl1*J) + sgn_r*r*Xl1 - Yl1*f;//经计算这里的Xl1*I+Yl1*J=0
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if ((sgn_r == 1 && ShunNi == -1) || (sgn_r == -1 && ShunNi == 1))//左刀补逆时针或右刀补顺时针
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3 - fabs(sgn_r*r)*Xl3;
Ys[i] = y1 + sgn_r*r*Xl3 - fabs(sgn_r*r)*Yl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
if (jinxing == 1 && temp3 == 0 && temp4 > 0)//进行时转接角为180度
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
//Xs[i] = x1 + Xl1*(Xl1*I + Yl1*J) - sgn_r*r*Yl1 - sgn(Xl1*I + Yl1*J)*Xl1*f;
//Ys[i] = y1 + Yl1*(Xl1*I + Yl1*J) + sgn_r*r*Xl1 - sgn(Xl1*I + Yl1*J)*Yl1*f;
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;//因为Xl1*I + Yl1*J在这里是0,所以上下两个公式其实一样
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
//########################伸长型###############################
else if (temp3 < 0 && temp4 >= 0)//转接角范围为[90,180)
{
if (jianli == 1)//伸长型刀补建立
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 + ((Xl3 - Xl1)*sgn_r*r) / (Xl1*Yl3 - Xl3*Yl1);
Ys[i] = y1 + ((Yl3 - Yl1)*sgn_r*r) / (Xl1*Yl3 - Xl3*Yl1);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (jinxing == 1)//伸长型刀补进行
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + ((Xl3 - Xl1)*sgn_r*r) / (Xl1*Yl3 - Xl3*Yl1);
Ys[i] = y1 + ((Yl3 - Yl1)*sgn_r*r) / (Xl1*Yl3 - Xl3*Yl1);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
//########################插入型###############################
else if (temp3 < 0 && temp4 < 0)//转接角范围为(0,90)
{
if (jianli == 1)//插入型刀补建立
{
Xs[i] = x0;//存进刀点
Ys[i] = y0;
i++;
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * x0, 40.0 * y0);
Xs[i] = x1 - sgn_r*r*Yl1;
Ys[i] = y1 + sgn_r*r*Xl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3 - fabs(sgn_r*r)*Xl3;
Ys[i] = y1 + sgn_r*r*Xl3 - fabs(sgn_r*r)*Yl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (jinxing == 1)//插入型刀补进行
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
pDC->LineTo(40.0 * x1, 40.0 * y1);
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx - r2), 40.0 * (Ry + r2), 40.0 * (Rx + r2), 40.0 * (Ry - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl1 + fabs(sgn_r*r)*Xl1;
Ys[i] = y1 + sgn_r*r*Xl1 + fabs(sgn_r*r)*Yl1;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3 - fabs(sgn_r*r)*Xl3;
Ys[i] = y1 + sgn_r*r*Xl3 - fabs(sgn_r*r)*Yl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl3;
Ys[i] = y1 + sgn_r*r*Xl3;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
}
/************圆弧接直线**************/
if (r2 == 0 && r1 != 0)//圆弧接直线判断条件
{
if (jianli == 1)
{
MessageBox("一般情况下,圆弧接直线转接时,圆弧不能作为进刀编程轨迹,请重新输入", "警告", NULL);
}
//####################缩短型###################################
if (temp5 > 0)//转接角范围为(180,360)
{
if (jinxing == 1)//缩短型刀补进行
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + Xl2*(Xl2*X01 + Yl2*Y01) - sgn_r*r*Yl2 - sgn(Xl2*X01 + Yl2*Y01)*Xl2*f1;
Ys[i] = y1 + Yl2*(Xl2*X01 + Yl2*Y01) + sgn_r*r*Xl2 - sgn(Xl2*X01 + Yl2*Y01)*Yl2*f1;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
j++;
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (chexiao == 1)//缩短型刀补撤销
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
//pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
//刀补撤销时i就不用再加1了
}
}
if (jinxing == 1 && temp5 == 0 && temp6 < 0)//进行时转接角为0度
{
if ((sgn_r == 1 && ShunNi == 1) || (sgn_r == -1 && ShunNi == -1))//左刀补顺时针或右刀补逆时针
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 + Xl2*(X01*Xl2 + Y01*Yl2) - sgn_r*r*Yl2 + Xl2*f1;
Ys[i] = y1 + Yl2*(X01*Xl2 + Y01*Yl2) + sgn_r*r*Xl2 - Yl2*f1;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
j++;
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if ((sgn_r == 1 && ShunNi == -1) || (sgn_r == -1 && ShunNi == 1))//左刀补逆时针或右刀补顺时针
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl4;
Ys[i] = y1 + sgn_r*r*Xl4;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
i++;
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl4 + fabs(sgn_r*r)*Xl4;
Ys[i] = y1 + sgn_r*r*Xl4 + fabs(sgn_r*r)*Yl4;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
if (jinxing == 1 && temp5 == 0 && temp6 > 0)//进行时转接角为180度
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
if (chexiao == 1 && temp5 == 0 && temp6 < 0)//撤消时转接角为0度
{
MessageBox("圆弧接直线刀补撤消时,转接角α=0会导致刀具干涉,请重新输入", "警告", NULL);
}
if (chexiao == 1 && temp5 == 0 && temp6 > 0)//撤消时转接角为180度
{
pDC->MoveTo(40.0 * x0, 40.0 * y0);
//pDC->LineTo(40.0 * x1, 40.0 * y1);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
}
//########################伸长型###############################
else if (temp5 < 0 && temp6 >= 0)//转接角范围为[90,180)
{
if (jinxing == 1)//伸长型刀补进行
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl4;
Ys[i] = y1 + sgn_r*r*Xl4;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 + ((Xl2 - Xl4)*sgn_r*r) / (Xl4*Yl2 - Xl2*Yl4);
Ys[i] = y1 + ((Yl2 - Yl4)*sgn_r*r) / (Xl4*Yl2 - Xl2*Yl4);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (chexiao == 1)//伸长型刀补撤销
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
//pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl4;
Ys[i] = y1 + sgn_r*r*Xl4;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 + ((Xl2 - Xl4)*sgn_r*r) / (Xl4*Yl2 - Xl2*Yl4);
Ys[i] = y1 + ((Yl2 - Yl4)*sgn_r*r) / (Xl4*Yl2 - Xl2*Yl4);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
//刀补撤销时i就不用再加1了
}
}
//########################插入型###############################
else if (temp5 < 0 && temp6 < 0)//转接角范围为(0,90)
{
if (jinxing == 1)//插入型刀补进行
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl4;
Ys[i] = y1 + sgn_r*r*Xl4;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl4 + fabs(sgn_r*r)*Xl4;
Ys[i] = y1 + sgn_r*r*Xl4 + fabs(sgn_r*r)*Yl4;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else if (chexiao == 1)//插入型刀补撤销
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
//pDC->LineTo(40.0 * x2, 40.0 * y2);
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl4;
Ys[i] = y1 + sgn_r*r*Xl4;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R10, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R10), 40.0 * (Ry0 + R10), 40.0 * (Rx0 + R10), 40.0 * (Ry0 - R10), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl4 + fabs(sgn_r*r)*Xl4;
Ys[i] = y1 + sgn_r*r*Xl4 + fabs(sgn_r*r)*Yl4;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2 - fabs(sgn_r*r)*Xl2;
Ys[i] = y1 + sgn_r*r*Xl2 - fabs(sgn_r*r)*Yl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl2;
Ys[i] = y1 + sgn_r*r*Xl2;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
Xs[i] = x2;
Ys[i] = y2;
pDC->LineTo(40.0 * x2, 40.0 * y2);
//刀补撤销时i就不用再加1了
}
}
}
/************圆弧接圆弧**************/
if (r1 != 0 && r2 != 0)//圆弧接圆弧判断条件
{
//####################缩短型###################################
if (jianli == 1 || chexiao == 1)
{
MessageBox("一般情况下,圆弧接圆弧转接时,不能作为进刀或退刀编程轨迹,请重新输入", "警告", NULL);
}
if (temp7 > 0)//转接角范围为(180,360)
{
if (jinxing == 1)//缩短型刀补进行
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi2 == -1)
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
//Xs[i] = x1 + XL*(XL*X02 + YL*Y02) - d4*YL - sgn(XL*X02 + YL*Y02)*XL*f2;
//Ys[i] = y1 + YL*(XL*X02 + YL*Y02) + d4*XL - sgn(XL*X02 + YL*Y02)*YL*f2;
Xs[i] = x1 + XL*(XL*X03 + YL*Y03) - d4*YL - sgn(XL*X03 + YL*Y03)*XL*f2;
Ys[i] = y1 + YL*(XL*X03 + YL*Y03) + d4*XL - sgn(XL*X03 + YL*Y03)*YL*f2;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R20, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
if (jinxing == 1 && temp7 == 0 && temp8 < 0)//转接角为0度
{
int sgnval;
if(((ShunNi==ShunNi2) && ((ShunNi==1 && sgn_r==1) || (ShunNi==-1 && sgn_r==-1))) ||
((ShunNi!=ShunNi2) && (r1r2) && ((ShunNi==-1 && sgn_r==1) || (ShunNi==1 && sgn_r==1)))
)
//两段圆弧方向一样时:左刀补顺时针或右刀补逆时针(一个转接点)
//两段圆弧方向不一样且第一段圆弧半径小于第二段时:左刀补顺时针或右刀补逆时针
//两段圆弧方向不一样且第一段圆弧半径大于第二段时:左刀补逆时针或右刀补顺时针
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi2 == -1)
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
if (ShunNi == ShunNi2)
{
if (sgn_r == 1)//外切左刀补
{
sgnval = 1;
}
if (sgn_r == -1)//外切右刀补
{
sgnval = -1;
}
}
else
{
if (sgn_r == 1)//内切左刀补
{
sgnval = -1;
}
if (sgn_r == -1)//内切右刀补
{
sgnval = 1;
}
}
Xs[i] = x1 + XL*(XL*X03 + YL*Y03) - d4*YL - sgnval*XL*f2;
Ys[i] = y1 + YL*(XL*X03 + YL*Y03) + d4*XL - sgnval*YL*f2;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R20, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
else
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi2 == -1)
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl5;
Ys[i] = y1 + sgn_r*r*Xl5;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R20, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl5 + fabs(sgn_r*r)*Xl5;
Ys[i] = y1 + sgn_r*r*Xl5 + fabs(sgn_r*r)*Yl5;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl6 - fabs(sgn_r*r)*Xl6;
Ys[i] = y1 + sgn_r*r*Xl6 - fabs(sgn_r*r)*Yl6;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
if (jinxing == 1 && temp7 == 0 && temp8 > 0)//转接角为180度
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi2 == -1)
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl5;
Ys[i] = y1 + sgn_r*r*Xl5;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R20, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
//########################伸长型###############################
else if (temp7 < 0 && temp8 >= 0)//转接角范围为[90,180)
{
if (jinxing == 1)//伸长型刀补进行
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi2 == -1)
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl5;
Ys[i] = y1 + sgn_r*r*Xl5;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R20, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
j++;
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 + ((Xl6 - Xl5)*sgn_r*r) / (Xl5*Yl6 - Xl6*Yl5);
Ys[i] = y1 + ((Yl6 - Yl5)*sgn_r*r) / (Xl5*Yl6 - Xl6*Yl5);
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl6;
Ys[i] = y1 + sgn_r*r*Xl6;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
//########################插入型###############################
else if (temp7 < 0 && temp8 < 0)//转接角范围为(0,90)
{
if (jinxing == 1)//插入型刀补进行
{
pDC->MoveTo(40.0 * x1, 40.0 * y1);
if (ShunNi2 == -1)
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x1, 40.0 * y1, 40.0 * x2, 40.0 * y2);
}
else
{
pDC->Arc(40.0 * (Rx3 - r2), 40.0 * (Ry3 + r2), 40.0 * (Rx3 + r2), 40.0 * (Ry3 - r2), 40.0 * x2, 40.0 * y2, 40.0 * x1, 40.0 * y1);
}
Cjhshb(pDC);
pDC->MoveTo(40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Xs[i] = x1 - sgn_r*r*Yl5;
Ys[i] = y1 + sgn_r*r*Xl5;
ZhixianOrYuanhu[j] = -1;
double Rx0, Ry0;
YuanXin(Xs[i - 1], Ys[i - 1], Xs[i], Ys[i], R20, Rx0, Ry0);
Xyuanhu[j] = Rx0;
Yyuanhu[j] = Ry0;
if (ShunNi == -1)
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i - 1], 40.0 * Ys[i - 1], 40.0 * Xs[i], 40.0 * Ys[i]);
Ryuanhu[j] = -R10;
}
else
{
pDC->Arc(40.0 * (Rx0 - R20), 40.0 * (Ry0 + R20), 40.0 * (Rx0 + R20), 40.0 * (Ry0 - R20), 40.0 * Xs[i], 40.0 * Ys[i], 40.0 * Xs[i - 1], 40.0 * Ys[i - 1]);
Ryuanhu[j] = R10;
}
pDC->MoveTo(40.0 * Xs[i], 40.0 * Ys[i]);
j++;
i++;
Xs[i] = x1 - sgn_r*r*Yl5 + fabs(sgn_r*r)*Xl5;
Ys[i] = y1 + sgn_r*r*Xl5 + fabs(sgn_r*r)*Yl5;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl6 - fabs(sgn_r*r)*Xl6;
Ys[i] = y1 + sgn_r*r*Xl6 - fabs(sgn_r*r)*Yl6;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
Xs[i] = x1 - sgn_r*r*Yl6;
Ys[i] = y1 + sgn_r*r*Xl6;
ZhixianOrYuanhu[j] = 1;
j++;
pDC->LineTo(40.0 * Xs[i], 40.0 * Ys[i]);
i++;
x0 = x1*ZuoBiaobl;y0 = y1*ZuoBiaobl;x1 = x2*ZuoBiaobl;y1 = y2*ZuoBiaobl;x2 = 0;y2 = 0;
r1 = r1*ZuoBiaobl;r2 = r2*ZuoBiaobl;r = r*ZuoBiaobl;
UpdateData(false);
}
}
}
}
//********************************开始插补**************************
void CMyDlg::OnZhudianbijiaofa() //逐点比较法插补
{
// TODO: Add your control notification handler code here
UpdateData(true);
CPaintDC dc(this);
CDC *pDC = pWnd->GetDC();//获取控件指针
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetViewportOrg(800 / 2, 700 / 2);
pDC->SetViewportExt(800, 700);
pDC->SetWindowOrg(0, 0);
pDC->SetWindowExt(1000, -1000);
Cjlshb(pDC);
int n = 0;
for (n;n <= j;n++)
{
if (ZhixianOrYuanhu[n] == 1)//四象限直线插补
{
double X0 = Xs[n];
double Y0 = Ys[n];
double Xe = Xs[n + 1];
double Ye = Ys[n + 1];
double Xi = X0;
double Yi = Y0;
pDC->MoveTo(40.0*X0, 40.0*Y0);
if (Xe > X0 && Ye > Y0)//第一象限方向(不是第一象限)
{
if (Xe - Xi >= Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
pDC->LineTo(40.0*Xi, 40.0*Yi);
Sleep(Time);
while (Xi != Xe || Yi != Ye)
{
double F;
if (Yi == Y0)
{
F = -1;
}
else
{
F = ((Yi - Y0) / (Xi - X0)) - ((Ye - Y0) / (Xe - X0));
}
if (F >= 0)
{
if (Xe - Xi >= Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Ye - Yi >= Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
}
pDC->LineTo(40.0*Xi, 40.0*Yi);
Sleep(Time);
}
}
if (Xe < X0 && Ye > Y0)//第二象限方向(不是第二象限)
{
if (Xe - Xi <= -Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
while (Xi != Xe || Yi != Ye)
{
double F;
if (Yi == Y0)
{
F = 1;
}
else
{
F = ((Yi - Y0) / (Xi - X0)) - ((Ye - Y0) / (Xe - X0));
}
if (F <= 0)
{
if (Xe - Xi <= -Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Ye - Yi >= Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
if (Xe < X0 && Ye < Y0)//第三象限方向(不是第三象限)
{
if (Xe - Xi <= -Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
while (Xi != Xe || Yi != Ye)
{
double F;
if (Yi == Y0)
{
F = -1;
}
else
{
F = ((Yi - Y0) / (Xi - X0)) - ((Ye - Y0) / (Xe - X0));
}
if (F >= 0)
{
if (Xe - Xi <= -Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Ye - Yi <= -Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
if (Xe > X0 && Ye < Y0)//第四象限方向(不是第四象限)
{
if (Xe - Xi >= Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
while (Xi != Xe || Yi != Ye)
{
double F;
if (Yi == Y0)
{
F = 1;
}
else
{
F = ((Yi - Y0) / (Xi - X0)) - ((Ye - Y0) / (Xe - X0));
}
if (F <= 0)
{
if (Xe - Xi >= Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Ye - Yi <= -Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
if (Xe > X0 && Ye == Y0)//X轴正方向
{
while (Xi != Xe || Yi != Ye)
{
if (Xe - Xi >= Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
if (Xe < X0 && Ye == Y0)//X轴负方向
{
while (Xi != Xe || Yi != Ye)
{
if (Xe - Xi <= -Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
if (Ye > Y0 && Xe == X0)//Y轴正方向
{
while (Xi != Xe || Yi != Ye)
{
if (Ye - Yi >= Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
if (Ye < Y0 && Xe == X0)//Y轴负方向
{
while (Xi != Xe || Yi != Ye)
{
if (Ye - Yi <= -Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
}
if (ZhixianOrYuanhu[n] == -1)//四象限圆弧插补
{
double Xi = Xs[n];
double Yi = Ys[n];
double Xe = Xs[n + 1];
double Ye = Ys[n + 1];
pDC->MoveTo(40.0*Xi, 40.0*Yi);
if (Ryuanhu[n] < 0)//逆圆
{
while (Xi != Xe || Yi != Ye)
{
if (Xi > Xyuanhu[n] && Yi >= Yyuanhu[n])//圆弧相对于圆心的角度为[0,90)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe > Xyuanhu[n] && Ye >= Yyuanhu[n])//如果终点在相对于原点的第一象限方向
{
if (Xi - Xe >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Xi - Xyuanhu[n] >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xyuanhu[n];
}
}
}
else
{
if (Xe > Xyuanhu[n] && Ye >= Yyuanhu[n])//如果终点在相对于原点的第一象限方向
{
if (Yi - Ye <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
}
else if (Yi < (Yyuanhu[n] + fabs(Ryuanhu[n])))
{
if (Yi - (Yyuanhu[n] + fabs(Ryuanhu[n])) <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Yyuanhu[n] + fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
if (Xi <= Xyuanhu[n] && Yi > Yyuanhu[n])//圆弧相对于圆心的角度为[90,180)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe <= Xyuanhu[n] && Ye > Yyuanhu[n])//如果终点在相对于原点的第二象限方向
{
if (Yi - Ye >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
}
else
{
if (Yi - Yyuanhu[n] >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Yyuanhu[n];
}
}
}
else
{
if (Xe <= Xyuanhu[n] && Ye > Yyuanhu[n])//如果终点在相对于原点的第二象限方向
{
if (Xi - Xe >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
}
else if (Xi > (Xyuanhu[n] - fabs(Ryuanhu[n])))
{
if (Xi - (Xyuanhu[n] - fabs(Ryuanhu[n])) >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xyuanhu[n] - fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
if (Xi < Xyuanhu[n] && Yi <= Yyuanhu[n])//圆弧相对于圆心的角度为[180,270)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe < Xyuanhu[n] && Ye <= Yyuanhu[n])//如果终点在相对于原点的第三象限方向
{
if (Xi - Xe <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Xi - Xyuanhu[n] <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xyuanhu[n];
}
}
}
else
{
if (Xe < Xyuanhu[n] && Ye <= Yyuanhu[n])//如果终点在相对于原点的第三象限方向
{
if (Yi - Ye >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
}
else if (Yi > (Yyuanhu[n] - fabs(Ryuanhu[n])))
{
if (Yi - (Yyuanhu[n] - fabs(Ryuanhu[n])) >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Yyuanhu[n] - fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
if (Xi >= Xyuanhu[n] && Yi < Yyuanhu[n])//圆弧相对于圆心的角度为[270,360)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe >= Xyuanhu[n] && Ye < Yyuanhu[n])//如果终点在相对于原点的第四象限方向
{
if (Yi - Ye <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
}
else
{
if (Yi - Yyuanhu[n] <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Yyuanhu[n];
}
}
}
else
{
if (Xe >= Xyuanhu[n] && Ye < Yyuanhu[n])//如果终点在相对于原点的第四象限方向
{
if (Xi - Xe <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
}
else if (Xi < (Xyuanhu[n] + fabs(Ryuanhu[n])))
{
if (Xi - (Xyuanhu[n] + fabs(Ryuanhu[n])) <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xyuanhu[n] + fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
}
else if (Ryuanhu[n] > 0)//顺圆
{
while (Xi != Xe || Yi != Ye)
{
if (Xi >= Xyuanhu[n] && Yi > Yyuanhu[n])//圆弧相对于圆心的角度为[90,0)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe >= Xyuanhu[n] && Ye > Yyuanhu[n])//如果终点在相对于原点的第一象限方向
{
if (Yi - Ye >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
}
else
{
if (Yi - Yyuanhu[n] >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Yyuanhu[n];
}
}
}
else
{
if (Xe >= Xyuanhu[n] && Ye > Yyuanhu[n])//如果终点在相对于原点的第一象限方向
{
if (Xi - Xe <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
}
else if (Xi < (Xyuanhu[n] + fabs(Ryuanhu[n])))
{
if (Xi - (Xyuanhu[n] + fabs(Ryuanhu[n])) <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xyuanhu[n] + fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
if (Xi < Xyuanhu[n] && Yi >= Yyuanhu[n])//圆弧相对于圆心的角度为[180,90)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe < Xyuanhu[n] && Ye >= Yyuanhu[n])//如果终点在相对于原点的第二象限方向
{
if (Xi - Xe <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Xi - Xyuanhu[n] <= -Delta)
{
Xi = Xi + Delta;
}
else
{
Xi = Xyuanhu[n];
}
}
}
else
{
if (Xe < Xyuanhu[n] && Ye >= Yyuanhu[n])//如果终点在相对于原点的第二象限方向
{
if (Yi - Ye <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
}
else if (Yi < (Yyuanhu[n] + fabs(Ryuanhu[n])))
{
if (Yi - (Yyuanhu[n] + fabs(Ryuanhu[n])) <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Yyuanhu[n] + fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
if (Xi <= Xyuanhu[n] && Yi < Yyuanhu[n])//圆弧相对于圆心的角度为[270,180)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe <= Xyuanhu[n] && Ye < Yyuanhu[n])//如果终点在相对于原点的第三象限方向
{
if (Yi - Ye <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Ye;
}
}
else
{
if (Yi - Yyuanhu[n] <= -Delta)
{
Yi = Yi + Delta;
}
else
{
Yi = Yyuanhu[n];
}
}
}
else
{
if (Xe <= Xyuanhu[n] && Ye < Yyuanhu[n])//如果终点在相对于原点的第三象限方向
{
if (Xi - Xe >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
}
else if (Xi > (Xyuanhu[n] - fabs(Ryuanhu[n])))
{
if (Xi - (Xyuanhu[n] - fabs(Ryuanhu[n])) >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xyuanhu[n] - fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
if (Xi > Xyuanhu[n] && Yi <= Yyuanhu[n])//圆弧相对于圆心的角度为[360,270)
{
double F = ((Xi - Xyuanhu[n])*(Xi - Xyuanhu[n]) + (Yi - Yyuanhu[n])*(Yi - Yyuanhu[n])) - Ryuanhu[n] * Ryuanhu[n];
if (F >= 0)
{
if (Xe > Xyuanhu[n] && Ye <= Yyuanhu[n])//如果终点在相对于原点的第四象限方向
{
if (Xi - Xe > Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xe;
}
}
else
{
if (Xi - Xyuanhu[n] >= Delta)
{
Xi = Xi - Delta;
}
else
{
Xi = Xyuanhu[n];
}
}
}
else
{
if (Xe > Xyuanhu[n] && Ye <= Yyuanhu[n])//如果终点在相对于原点的第四象限方向
{
if (Yi - Ye >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Ye;
}
}
else if (Yi > (Yyuanhu[n] - fabs(Ryuanhu[n])))
{
if (Yi - (Yyuanhu[n] - fabs(Ryuanhu[n])) >= Delta)
{
Yi = Yi - Delta;
}
else
{
Yi = Yyuanhu[n] - fabs(Ryuanhu[n]);
}
}
}
pDC->LineTo(40.0 * Xi, 40.0 * Yi);
Sleep(Time);
}
}
}
}
}
}
void CMyDlg::OnShuZiJiFenFa() //数字积分法插补
{
// TODO: Add your control notification handler code here
UpdateData(true);
CPaintDC dc(this);
CDC *pDC = pWnd->GetDC();//获取控件指针
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetViewportOrg(800 / 2, 700 / 2);
pDC->SetViewportExt(800, 700);
pDC->SetWindowOrg(0, 0);
pDC->SetWindowExt(1000, -1000);
Cjlshb(pDC);
int n = 0;
for (n;n <= j;n++)
{
if (ZhixianOrYuanhu[n] == 1)//四象限直线插补
{
double X0 = Xs[n];
double Y0 = Ys[n];
double Jvx = Xs[n + 1];//插补终点
double Jvy = Ys[n + 1];
int sigma = pow(2, N);
if (fabs(Jvx) > sigma || fabs(Jvy) > sigma)
{
MessageBox("寄存器位数与实际参数不匹配,请重新输入", "警告", NULL);
break;
}
double Jrx = sigma / step/2;//半加载法寄存器余数
double Jry = sigma / step/2;
int Jsigma = sigma / step;//累加器容量
int count = 0;//累加值
bool Qx = false;
bool Qy = false;
pDC->MoveTo(40.0*X0, 40.0*Y0);
if (Jvx >= X0 && Jvy >= Y0)//第一象限方向
{
while (count < Jsigma)
{
Jrx = Jrx + (Jvx - Xs[n]) / step;
Jry = Jry + (Jvy - Ys[n]) / step;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx-Jsigma;
}
X0 = X0 + step;
Qx = true;
}
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry-Jsigma;
}
Y0 = Y0 + step;
Qy = true;
}
if (Qx || Qy)
{
pDC->LineTo(40.0 * X0, 40.0 * Y0);
Qx = Qy = false;
}
count++;
Sleep(Time);
}
pDC->LineTo(40.0*Jvx, 40.0*Jvy);
}
Jrx = sigma / step / 2;//寄存器余数
Jry = sigma / step / 2;
if (Jvx < X0 && Jvy >= Y0)//第二象限方向
{
while (count < Jsigma)
{
Jrx = Jrx + fabs(Jvx - Xs[n]) / step;
Jry = Jry + (Jvy - Ys[n]) / step;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx-Jsigma;
}
X0 = X0 - step;
Qx = true;
}
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry-Jsigma;
}
Y0 = Y0 + step;
Qy = true;
}
if (Qx || Qy)
{
pDC->LineTo(40.0 * X0, 40.0 * Y0);
Qx = Qy = false;
}
count++;
Sleep(Time);
}
pDC->LineTo(40.0*Jvx, 40.0*Jvy);
}
Jrx = sigma / step / 2;//寄存器余数
Jry = sigma / step / 2;
if (Jvx < X0 && Jvy < Y0)//第三象限方向
{
while (count < Jsigma)
{
Jrx = Jrx + fabs(Jvx - Xs[n]) / step;
Jry = Jry + fabs(Jvy - Ys[n]) / step;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx-Jsigma;
}
X0 = X0 - step;
Qx = true;
}
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry-Jsigma;
}
Y0 = Y0 - step;
Qy = true;
}
if (Qx || Qy)
{
pDC->LineTo(40.0 * X0, 40.0 * Y0);
Qx = Qy = false;
}
count++;
Sleep(Time);
}
pDC->LineTo(40.0*Jvx, 40.0*Jvy);
}
Jrx = sigma / step / 2;//寄存器余数
Jry = sigma / step / 2;
if (Jvx >= X0 && Jvy < Y0)//第四象限方向
{
while (count < Jsigma)
{
Jrx = Jrx + (Jvx - Xs[n]) / step;
Jry = Jry + fabs(Jvy - Ys[n]) / step;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx-Jsigma;
}
X0 = X0 + step;
Qx = true;
}
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry-Jsigma;
}
Y0 = Y0 - step;
Qy = true;
}
if (Qx || Qy)
{
pDC->LineTo(40.0 * X0, 40.0 * Y0);
Qx = Qy = false;
}
count++;
Sleep(Time);
}
pDC->LineTo(40.0*Jvx, 40.0*Jvy);
}
}
if (ZhixianOrYuanhu[n] == -1)//四象限圆弧插补
{
double X0 = Xs[n];
double Y0 = Ys[n];
double Xe = Xs[n + 1];
double Ye = Ys[n + 1];
int sigma = pow(2, N);
double Jrx = sigma/2;//半加载法寄存器余数
double Jry = sigma/2;
double Jvx;
double Jvy;
if (fabs(X0) > sigma || fabs(Y0) > sigma || fabs(Xe) > sigma || fabs(Ye) > sigma)
{
MessageBox("寄存器位数与实际参数不匹配,请重新输入", "警告", NULL);
break;
}
int Jsigma = sigma;//累加器容量
bool Qx = false;
bool Qy = false;
double Jsigmax;
double Jsigmay;
double Xe1;
double Ye1;
pDC->MoveTo(40.0*X0, 40.0*Y0);
if ((Ryuanhu[n] < 0))//逆圆
{
while (X0 != Xe || Y0 != Ye)
{
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma / 2;//半加载法寄存器余数
Jry = sigma / 2;
if (X0 > Xyuanhu[n] && Y0 >= Yyuanhu[n])//第一象限方向
{
if (Xe > Xyuanhu[n] && Ye >= Yyuanhu[n])//终点在第一象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第一象限
{
Jsigmax = fabs(Xyuanhu[n] - X0) / step;
Jsigmay = fabs(Yyuanhu[n] + fabs(Ryuanhu[n]) - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n];
Ye1 = Yyuanhu[n] + fabs(Ryuanhu[n]);
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)//只能这样,double型不能取余
{
Jrx = Jrx - Jsigma;
}
X0 -= step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 += step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma/2;//半加载法寄存器余数
Jry = sigma/2;
if (X0 <= Xyuanhu[n] && Y0 > Yyuanhu[n])//第二象限方向
{
if (Xe <= Xyuanhu[n] && Ye > Yyuanhu[n])//终点在第二象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第二象限
{
Jsigmax = fabs(Xyuanhu[n] - fabs(Ryuanhu[n]) - X0) / step;
Jsigmay = fabs(Yyuanhu[n] - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n] - fabs(Ryuanhu[n]);
Ye1 = Yyuanhu[n];
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 -= step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 -= step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma/2;//半加载法寄存器余数
Jry = sigma/2;
if (X0 < Xyuanhu[n] && Y0 <= Yyuanhu[n])//第三象限方向
{
if (Xe < Xyuanhu[n] && Ye <= Yyuanhu[n])//终点在第三象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第三象限
{
Jsigmax = fabs(Xyuanhu[n] - X0) / step;
Jsigmay = fabs(Yyuanhu[n] - fabs(Ryuanhu[n]) - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n];
Ye1 = Yyuanhu[n] - fabs(Ryuanhu[n]);
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 += step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 -= step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma/2;//半加载法寄存器余数
Jry = sigma/2;
if (X0 >= Xyuanhu[n] && Y0 < Yyuanhu[n])//第四象限方向
{
if (Xe >= Xyuanhu[n] && Ye < Yyuanhu[n])//终点在第四象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第四象限
{
Jsigmax = fabs(Xyuanhu[n] + fabs(Ryuanhu[n]) - X0) / step;
Jsigmay = fabs(Yyuanhu[n] - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n] + fabs(Ryuanhu[n]);
Ye1 = Yyuanhu[n];
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 += step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 += step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
}
}
if ((Ryuanhu[n] > 0))//顺圆
{
while (X0 != Xe || Y0 != Ye)
{
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma / 2;//半加载法寄存器余数
Jry = sigma / 2;
if (X0 >= Xyuanhu[n] && Y0 > Yyuanhu[n])//第一象限方向
{
if (Xe >= Xyuanhu[n] && Ye > Yyuanhu[n])//终点在第一象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第一象限
{
Jsigmax = fabs(Xyuanhu[n] + fabs(Ryuanhu[n]) - X0) / step;
Jsigmay = fabs(Yyuanhu[n] - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n] + fabs(Ryuanhu[n]);
Ye1 = Yyuanhu[n];
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 += step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 -= step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma / 2;//半加载法寄存器余数
Jry = sigma / 2;
if (X0 < Xyuanhu[n] && Y0 >= Yyuanhu[n])//第二象限方向
{
if (Xe < Xyuanhu[n] && Ye >= Yyuanhu[n])//终点在第二象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第二象限
{
Jsigmax = fabs(Xyuanhu[n] - X0) / step;
Jsigmay = fabs(Yyuanhu[n] + fabs(Ryuanhu[n]) - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n];
Ye1 = Yyuanhu[n] + fabs(Ryuanhu[n]);
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 += step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 += step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma / 2;//半加载法寄存器余数
Jry = sigma / 2;
if (X0 <= Xyuanhu[n] && Y0 < Yyuanhu[n])//第三象限方向
{
if (Xe <= Xyuanhu[n] && Ye < Yyuanhu[n])//终点在第三象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第三象限
{
Jsigmax = fabs(Xyuanhu[n] - fabs(Ryuanhu[n]) - X0) / step;
Jsigmay = fabs(Yyuanhu[n] - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n] - fabs(Ryuanhu[n]);
Ye1 = Yyuanhu[n];
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 -= step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 += step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
if (fabs(X0 - Xyuanhu[n]) < Minnum)
{
X0 = Xyuanhu[n];
}
if (fabs(Y0 - Yyuanhu[n]) < Minnum)
{
Y0 = Yyuanhu[n];
}
Jrx = sigma / 2;//半加载法寄存器余数
Jry = sigma / 2;
if (X0 > Xyuanhu[n] && Y0 <= Yyuanhu[n])//第四象限方向
{
if (Xe > Xyuanhu[n] && Ye <= Yyuanhu[n])//终点在第四象限方向
{
Jsigmax = fabs(Xe - X0) / step;
Jsigmay = fabs(Ye - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xe;
Ye1 = Ye;
}
else//终点不在第四象限
{
Jsigmax = fabs(Xyuanhu[n] - X0) / step;
Jsigmay = fabs(Yyuanhu[n] - fabs(Ryuanhu[n]) - Y0) / step;
SiSheWuRu(Jsigmax);
SiSheWuRu(Jsigmay);
Xe1 = Xyuanhu[n];
Ye1 = Yyuanhu[n] - fabs(Ryuanhu[n]);
}
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
while (Jsigmax > 0 || Jsigmay > 0)
{
if (Jsigmax > 0)
{
Jrx += Jvx;
if (Jrx >= Jsigma)
{
while (Jrx >= Jsigma)
{
Jrx = Jrx - Jsigma;
}
X0 -= step;
Jsigmax -= 1;
Qx = true;
}
}
if (Jsigmay > 0)
{
Jry += Jvy;
if (Jry >= Jsigma)
{
while (Jry >= Jsigma)
{
Jry = Jry - Jsigma;
}
Y0 -= step;
Jsigmay -= 1;
Qy = true;
}
}
if (Qx || Qy)
{
pDC->LineTo(40.0*X0, 40.0*Y0);
Sleep(Time);
Qx = Qy = false;
Jvx = fabs(Y0 - Yyuanhu[n]);
Jvy = fabs(X0 - Xyuanhu[n]);
}
}
pDC->LineTo(40.0*Xe1, 40.0*Ye1);
X0 = Xe1;
Y0 = Ye1;
}
}
}
}
}
}