⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tview.cpp

📁 用最小二乘法计算分形图案的维数。试试看怎么样。请多包涵!!
💻 CPP
字号:
// tView.cpp : implementation of the CTView class
//

#include "stdafx.h"
#include "t.h"
#include "math.h"

#include "tDoc.h"
#include "tView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTView

IMPLEMENT_DYNCREATE(CTView, CView)

BEGIN_MESSAGE_MAP(CTView, CView)
	//{{AFX_MSG_MAP(CTView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CTView construction/destruction

CTView::CTView()
{
	// TODO: add construction code here

}

CTView::~CTView()
{
}

BOOL CTView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTView drawing
double a[4]={1.578684,1.599420,1.617363,1.640096};
double b[4]={0.017094,0.011905,0.007968,0.005602};
double c[4]={1000.,2000.,4000.,8000.};
void CTView::OnDraw(CDC* pDC)
{
	CTDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	int i;
	double aa=0.,bb=0.,m=0.,n=0.,k,l;
	for(i=0;i<4;i++)
		c[i]=150*b[i];
	for(i=0;i<4;i++)
	{
		aa+=a[i];bb+=c[i];
	}
	aa/=4;bb/=4;
	for(i=0;i<4;i++)
	{
		m+=((a[i]-aa)*(c[i]-bb));
		n+=((c[i]-bb)*(c[i]-bb));
	}
	k=m/sqrt(n);
	l=aa-k*bb;
	CString s;
	s.Format("%f  %f",k,l);
	CClientDC p(this);
	p.TextOut(11,22,s);

	for(i=0;i<4;i++)
	{
		m=l+k*b[i];
		s.Format("%f   ",m);
		p.TextOut(i*80,200,s);
	}

	

}

/////////////////////////////////////////////////////////////////////////////
// CTView printing

BOOL CTView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CTView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CTView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CTView diagnostics

#ifdef _DEBUG
void CTView::AssertValid() const
{
	CView::AssertValid();
}

void CTView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CTDoc* CTView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTDoc)));
	return (CTDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTView message handlers

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -