Triangle.cpp
上传用户:azhong891
上传日期:2013-06-04
资源大小:197k
文件大小:1k
- // Triangle.cpp: implementation of the CTriangle class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Delaunay.h"
- #include "pointpos.h"
- #include "Triangle.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- IMPLEMENT_SERIAL(CTriangle,CObject,1) //
- CTriangle::CTriangle()
- {
- }
- CTriangle::~CTriangle()
- {
- }
- void CTriangle::Serialize(CArchive& ar) //////
- {
- if(ar.IsStoring())
- {
- ar<<m_p1<<m_p2<<m_p3;
- ar<<m_xc<<m_yc<<m_rad;
- ar<<m_x<<m_y;
- }
- else
- {
- ar>>m_p1>>m_p2>>m_p3;
- ar>>m_xc>>m_yc>>m_rad;
- ar>>m_x>>m_y;
- }
- }
- POS CTriangle::Where(CPointPos *pos)
- {
- //点与外接圆
- //think of 点在边上,?????
- double distance;
- distance=sqrt((pos->m_x-m_xc)*(pos->m_x-m_xc)+(pos->m_y-m_yc)*(pos->m_y-m_yc));
- if(fabs(distance-m_rad)<0.0000000001)
- {
- AfxMessageBox("Four points in a circle,need a new ponit");
- return POS_ERROR;
- }
-
- if(distance<m_rad)
- {
- return POS_ON;//in circle =2;
- }
- return POS_OUT;//0
- }
- CTriangle::CTriangle(int p1, int p2, int p3)
- {
- m_p1=p1;
- m_p2=p2;
- m_p3=p3;
- }