#if !defined(AFX_BEZIERVIEW_H__80352B3B_A11D_4517_8F11_857005A5F1C4__INCLUDED_)
#define AFX_BEZIERVIEW_H__80352B3B_A11D_4517_8F11_857005A5F1C4__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
const int N=5;
const int npoints=100;
class Point
{
public:
double x,y;
Point(){x=0;y=0;};
Point(double _x,double _y){x=_x;y=_y;};
Point(CPoint p){x=p.x;y=p.y;};
inline Point operator=(Point p){x=p.x;y=p.y;return(*this);};
inline Point operator=(CPoint p){x=p.x;y=p.y;return(*this);};
inline Point operator+=(Point p){x+=p.x;y+=p.y;return(*this);};
inline Point operator+=(CPoint p){x+=p.x;y+=p.y;return(*this);};
inline Point operator-=(Point p){x-=p.x;y-=p.y;return(*this);};
inline Point operator-=(CPoint p){x-=p.x;y-=p.y;return(*this);};
inline Point operator*=(double s){x*=s;y*=s;return(*this);};
inline Point operator/=(double s){x/=s;y/=s;return(*this);};
inline Point operator+(Point p){Point t;t.x=x+p.x;t.y=y+p.y;return(t);};
inline Point operator+(CPoint p){Point t;t.x=x+p.x;t.y=y+p.y;return(t);};
inline Point operator-(Point p){Point t;t.x=x-p.x;t.y=y-p.y;return(t);};
inline Point operator-(CPoint p){Point t;t.x=x-p.x;t.y=y-p.y;return(t);};
inline Point operator*(double s){Point t;t.x=x*s.x;t.y=y*s;return(t);}; //這一句顯示錯誤
inline Point operator/(double s){Point t;t.x=x/s;t.y=y/s;return(t);};
inline operator CPoint(){return CPoint((int)x,(int)y);};
};
class CBezierView : public CView
{
protected: // create from serialization only
CBezierView();
DECLARE_DYNCREATE(CBezierView)
public:
int m_nCount;
CPoint m_Newpoint;
Point ptControlPts[N+1];
Point ptPts[npoints+1];
int nMethod;
public:
void DrawBezier(CDC* pDC, Point P[], int n,Point pts[],int npoints);
void bezier_to_points(Point P[], int n, Point pts[], int npoints);
Point Bezier(Point P[], int n, double t);
double Bernstein(int i,int n,double t);
long Permutation(int n,int i);
Point decas(Point P[],int n,double t);
void new_split_Bezier(CDC* pDC,Point P[]);
double maxdistance(Point P[]);
// Attributes
public:
CBezierDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBezierView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CBezierView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CBezierView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnBezierDecas();
afx_msg void OnUpdateBezierDecas(CCmdUI* pCmdUI);
afx_msg void OnBezierDirect();
afx_msg void OnUpdateBezierDirect(CCmdUI* pCmdUI);
afx_msg void OnBezierSplit();
afx_msg void OnUpdateBezierSplit(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in BezierView.cpp
inline CBezierDoc* CBezierView::GetDocument()
{ return (CBezierDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BEZIERVIEW_H__80352B3B_A11D_4517_8F11_857005A5F1C4__INCLUDED_)
uj5u.com熱心網友回復:
double ss.x
???
uj5u.com熱心網友回復:
inline Point operator*(double s){Point t;t.x=x*s.x;t.y=y*s;return(t);}; //這一句顯示錯誤應該是:
inline Point operator*(double s){Point t;t.x=x*s;t.y=y*s;return(t);};
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/87257.html
標籤:基礎類
下一篇:求大神說下可以用c語把網站上的資料一鍵匯入Excel表格不?大概說下方向就行了,小白自己研究苦于沒方向無法入手。謝謝啦
