各位在坐的csdn兄弟:
现在我正在做一些平面几何相关的东西,自己写起来太多,而且也没有什么时间了,请问有没有相关的平面几何算法库,比如直线交点,圆与直线交点,位置,多边形包含等类似算法的源代码,先谢谢了!
.cn

解决方案 »

  1.   

    矩形旋转变化 |C|
    // Rect1View.cpp : implementation of the CRect1View class
    //#include "stdafx.h"
    #include "Rect1.h"#include "Rect1Doc.h"
    #include "Rect1View.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CRect1ViewIMPLEMENT_DYNCREATE(CRect1View, CView)BEGIN_MESSAGE_MAP(CRect1View, CView)
    //{{AFX_MSG_MAP(CRect1View)
    // 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()/////////////////////////////////////////////////////////////////////////////
    // CRect1View construction/destructionCRect1View::CRect1View()
    {
    // TODO: add construction code here}CRect1View::~CRect1View()
    {
    }BOOL CRect1View::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs return CView::PreCreateWindow(cs);
    }/////////////////////////////////////////////////////////////////////////////
    // CRect1View drawingvoid CRect1View::OnDraw(CDC* pDC)
    {
    CRect1Doc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
    void rect1(int,int,double,double,CDC*);
    int i,xx,yy,xc=320,yc=240,c=100;
    long j;for(i=0;i<=360;i+=10)
      {
      xx=(int)(c*cos(i*3.14159/180)/6.0);
      yy=(int)(c*sin(i*3.14159/180)/6.0);
      rect1(xx,yy,c+i/3,i,pDC);
      for( j=0;j<10000000;j++);
      }
    }void rect1(int x,int y,double c,double a,CDC* pDC)
    {
    double x1,y1,x2,y2,x3,y3;
    double b,d;
    int x0=320,y0=240;x1=x+c*cos(a*3.14159/180);
    y1=y+c*sin(a*3.14159/180);
    b=c*tan(30*3.14159/180);
    d=sqrt(b*b+c*c);
    x2=x+d*cos((a+30)*3.14159/180);
    y2=y+d*sin((a+30)*3.14159/180);
    x3=x+b*cos((a+90)*3.14159/180);
    y3=y+b*sin((a+90)*3.14159/180);
    pDC->MoveTo((int)(x+x0),(int)(y+y0));
    pDC->LineTo((int)(x1+x0),(int)(y1+y0));pDC->LineTo((int)(x2+x0),(int)(y2+y0));
    pDC->LineTo((int)(x3+x0),(int)(y3+y0));pDC->LineTo((int)(x+x0),(int)(y+y0));
    }
    /////////////////////////////////////////////////////////////////////////////
    // CRect1View printingBOOL CRect1View::OnPreparePrinting(CPrintInfo* pInfo)
    {
    // default preparation
    return DoPreparePrinting(pInfo);
    }void CRect1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
    {
    // TODO: add extra initialization before printing
    }void CRect1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
    {
    // TODO: add cleanup after printing
    }/////////////////////////////////////////////////////////////////////////////
    // CRect1View diagnostics#ifdef _DEBUG
    void CRect1View::AssertValid() const
    {
    CView::AssertValid();
    }void CRect1View::Dump(CDumpContext& dc) const
    {
    CView::Dump(dc);
    }CRect1Doc* CRect1View::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRect1Doc)));
    return (CRect1Doc*)m_pDocument;
    }
    #endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
    // CRect1View message handlers
      

  2.   

    你给我一天 
    然后你把你的要求给我把
    呵呵
    [email protected]
    我给你函数