资源简介

B样条曲线反求控制点,已通过编译,测试OK! 计算机图形学必备知识!

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “BSpline.h“
#include “Math.h“

CBSpline::CBSpline(int nType)
{
m_nCtlCount=2;
m_nType=nType;
}

CBSpline::CBSpline(CBSpline* pBSpline)
{
m_nType=pBSpline->m_nType;
m_nCtlCount=pBSpline->m_nCtlCount;
for(int i=0;im_pKnot.GetSize();i++)
m_pKnot.Add(pBSpline->m_pKnot[i]);
for(i=0;im_ptControl.GetSize();i++)
m_ptControl.Add(pBSpline->m_ptControl[i]);
for(i=0;im_ptCurve.GetSize();i++)
m_ptCurve.Add(pBSpline->m_ptCurve[i]);
}
CBSpline::~CBSpline()
{
m_ptControl.RemoveAll();
m_ptControl.RemoveAll();
m_pKnot.RemoveAll();
}

void CBSpline::ReSetData()
{
m_nCtlCount=2;
m_ptControl.RemoveAll();
m_ptControl.RemoveAll();
m_pKnot.RemoveAll();
}
double CBSpline::base(int iint kdouble u)
{
if(k==1)
{
if((u>=m_pKnot[i])&&(u      return 1; 
     else
     return 0;
}
if(k==4)
if(i==m_nCtlCount && u==m_pKnot[m_nCtlCount])
return 1;

return DIV((u-m_pKnot[i])(m_pKnot[i+k-1]-m_pKnot[i]))*base(ik-1u)+
DIV((m_pKnot[i+k]-u)(m_pKnot[i+k]-m_pKnot[i+1]))*base(i+1k-1u);
}

void CBSpline::AddPoint(CPoint point)
{
m_ptCurve.Add(point);
m_nCtlCount++;

int nCount=m_ptCurve.GetSize();
if(m_pKnot.GetSize()==0)
{
for(int i=0;i<7;i++)
m_pKnot.Add(0.0);
}
else
{
double temp=(m_ptCurve[nCount-1].x-m_ptCurve[nCount-2].x)*
(m_ptCurve[nCount-1].x-m_ptCurve[nCount-2].x);
temp+=((m_ptCurve[nCount-1].y-m_ptCurve[nCount-2].y)*
(m_ptCurve[nCount-1].y-m_ptCurve[nCount-2].y));
temp=sqrt(temp);

nCount=m_pKnot.GetSize();
temp+=m_pKnot[nCount-1];
m_pKnot.SetAt(nCount-1temp);
m_pKnot.SetAt(nCount-2temp);
m_pKnot.SetAt(nCount-3temp);
     m_pKnot.Add(temp);
}
}
void CBSpline::MovePoint(CPoint point)
{
int nCount=m_nCtlCount-3;
m_ptCurve.SetAt(nCountpoint);
    double temp=(m_ptCurve[nCount].x-m_ptCurve[nCount-1].x)*
(m_ptCurve[nCount].x-m_ptCurve[nCount-1].x);
temp+=((m_ptCurve[nCount].y-m_ptCurve[nCount-1].y)*
(m_ptCurve[nCount].y-m_ptCurve[nCount-1].y));
temp=sqrt(temp);
nCount=m_pKnot.GetSize();
temp+=m_pKnot[nCount-5];
m_pKnot.SetAt(nCount-1temp);
m_pKnot.SetAt(nCount-2temp);
m_pKnot.SetAt(nCount-3temp);
m_pKnot.SetAt(nCount-4temp);
}
void CBSpline::RemovePoint()
{
m_ptCurve.RemoveAt(m_ptCurve.GetSize()-1);
m_nCtlCount--;
int nCount=m_pKnot.GetSize();
m_pKnot.SetAt(nCount-4m_pKnot[nCount-5]);
m_pKnot.SetAt(nCount-2m_pKnot[nCount-5]);
m_pKnot.SetAt(nCount-3m_pKnot[nCount-5]);
m_pKnot.RemoveAt(nCount-1);
}

void CBSpline::UpdateAll()
{
int i;
double temp1temp2;
Matrix* pMatrix=new Matrix[m_nCtlCount];
    Matrix* pLUMatrix=new Matrix[m_nCtlCount];
    double* pQx=new double[m_nCtlCount];
double* pQy=new double[m_nCtlCount];
double* pTempx=new double[m_nCtlCount];
double* pTempy=new double[m_nCtlCount];

m_ptControl.RemoveAll();
m_ptControl.ReSize(m_nCtlCount);

//第一与最后一点对应系

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2166  2018-03-04 09:26  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\ArrayEx.h

     文件       9407  2008-12-19 09:47  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\BSpline.cpp

     文件        805  2017-12-06 12:21  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\BSpline.h

     文件      43549  2018-03-04 09:26  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\BSpline.obj

     文件          0  2018-03-04 09:26  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\BSpline.sbr

     文件      20305  2017-12-06 01:19  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\MainFrm.obj

     文件          0  2017-12-06 01:19  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\MainFrm.sbr

     文件     105972  2017-12-06 01:19  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\StdAfx.obj

     文件    1375067  2017-12-06 01:19  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\StdAfx.sbr

     文件    4891648  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.bsc

     文件     143465  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.exe

     文件     420688  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.ilk

     文件      23613  2018-10-23 22:31  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.obj

     文件    6878208  2017-12-06 01:19  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.pch

     文件     508928  2018-10-23 22:31  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.pdb

     文件       7472  2017-12-06 01:19  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.res

     文件          0  2018-10-23 22:31  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_Bspline.sbr

     文件      45828  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_BsplineDoc.obj

     文件          0  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_BsplineDoc.sbr

     文件      35548  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_BsplineView.obj

     文件          0  2018-10-23 23:13  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\Test_BsplineView.sbr

     文件     222208  2019-01-28 20:05  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\vc60.idb

     文件     372736  2018-10-23 22:31  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\Debug\vc60.pdb

     文件       2653  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\MainFrm.cpp

     文件       1591  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\MainFrm.h

     文件       4420  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\ReadMe.txt

     文件       1078  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\res\Test_Bspline.ico

     文件        404  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\res\Test_Bspline.rc2

     文件       1078  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\res\Test_BsplineDoc.ico

     文件       1078  2008-12-18 17:39  B样条曲线反求控制点\B样条曲线反求控制点\B_spline curve\res\Toolbar.bmp

............此处省略27个文件信息

评论

共有 条评论