Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
записка.лянг.100.docx
Скачиваний:
1
Добавлен:
27.04.2019
Размер:
423.82 Кб
Скачать

Void vxod_dialog::OnLoadd()

{

FILE *file=fopen("saved.txt","rw");

char s[15];

fgets(s,15,file);

m_ab=atof(s);

fgets(s,15,file);

m_aa=atof(s);

fgets(s,15,file);

m_bc=atof(s);

fgets(s,15,file);

m_mk=atof(s);

fgets(s,15,file);

if(atoi(s)==1)m_com="1:1";

if(atoi(s)==4)m_com="1:4";

if(atoi(s)==5)m_com="1:5";

if(atoi(s)==20)m_com="1:20";

if(atoi(s)==25)m_com="1:25";

fgets(s,15,file);

m_dab=atof(s);

fgets(s,15,file);

m_gs=atof(s);

fgets(s,15,file);

m_kp=atof(s);

fgets(s,15,file);

m_bx=atof(s);

fgets(s,15,file);

m_by=atof(s);

fclose(file);

UpdateData(0);

}

zasyadkoView.cpp

// zasyadkoView.cpp : implementation of the CZasyadkoView class

//

#include "stdafx.h"

#include "zasyadko.h"

#include "math.h";

#include "zasyadkoDoc.h"

#include "zasyadkoView.h"

#include "vxod_dialog.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CZasyadkoView

Implement_dyncreate(cZasyadkoView, cView)

BEGIN_MESSAGE_MAP(CZasyadkoView, CView)

//{{AFX_MSG_MAP(CZasyadkoView)

ON_COMMAND(ID_VXOD, OnVxod)

ON_WM_TIMER()

ON_COMMAND(ID_STOP, OnStop)

ON_COMMAND(TRAEKTOR, OnTRAEKTOR)

//}}AFX_MSG_MAP

// Standard printing commands

ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CZasyadkoView construction/destruction

CZasyadkoView::CZasyadkoView()

{

// TODO: add construction code here

}

CZasyadkoView::~CZasyadkoView()

{

}

BOOL CZasyadkoView::PreCreateWindow(CREATESTRUCT& cs)

{

// TODO: Modify the Window class or styles here by modifying

// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);

}

/////////////////////////////////////////////////////////////////////////////

// CZasyadkoView drawing

void CZasyadkoView::OnDraw(CDC* pDC)

{

CZasyadkoDoc* pDoc = GetDocument();

ASSERT_VALID(pDoc);

// TODO: add draw code for native data here

}

/////////////////////////////////////////////////////////////////////////////

// CZasyadkoView printing

BOOL CZasyadkoView::OnPreparePrinting(CPrintInfo* pInfo)

{

// default preparation

return DoPreparePrinting(pInfo);

}

void CZasyadkoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)

{

// TODO: add extra initialization before printing

}

void CZasyadkoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)

{

// TODO: add cleanup after printing

}

/////////////////////////////////////////////////////////////////////////////

// CZasyadkoView diagnostics

#ifdef _DEBUG

void CZasyadkoView::AssertValid() const

{

CView::AssertValid();

}

void CZasyadkoView::Dump(CDumpContext& dc) const

{

CView::Dump(dc);

}

CZasyadkoDoc* CZasyadkoView::GetDocument() // non-debug version is inline

{

ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CZasyadkoDoc)));

return (CZasyadkoDoc*)m_pDocument;

}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////

// CZasyadkoView message handlers

void CZasyadkoView::Raschet()

{

ax=bx+cos(a*3.14/180)*ab;

ay=by+sin(a*3.14/180)*ab;

double z, z1, z2;

z=sqrt((cy-ay)*(cy-ay)+(cx-ax)*(cx-ax));

if(a>=70 && flag2==1)flag2=0;

else

if(flag2==0 && a>=70)flag2=1;

z1=(z*z+a1c*a1c-aa1*aa1)/(2*z*a1c);

z2=((cx-ax)*(cx-ax)+z*z-(by-ay)*(by-ay)) / (2*z*(cx-ax));

z1=fabs(z1);

z2=fabs(z2);

if(z1<1.000)z1=acos(z1);

else z1=acos(1);

if(z2<1.000)z2=acos(z2);

else z2=acos(1);

if(flag2==1)

b=(z1+z2)*180/3.14;

else

b=(z2-z1)*180/3.14;

a1x=cx-cos(b*3.14/180)*a1c;

a1y=cy+sin(b*3.14/180)*a1c;

mx=(ax+a1x)/2;

my=(a1y+ay)/2;

ky=+my+sqrt( km*km - (mx-kx)*(mx-kx) );

if(flag==1)a+=0.15;

else a-=0.15;

if(a>=70)flag=0;

if(a<=61 && a1x<=kx)flag=1;

if(a<=65 && a1x>=kx)flag=1;

}