📄 wmlintpvectorfield2.cpp
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#include "WmlIntpVectorField2.h"
using namespace Wml;
//----------------------------------------------------------------------------
template <class Real>
IntpVectorField2<Real>::IntpVectorField2 (int iQuantity,
Vector2<Real>* akInput, Vector2<Real>* akOutput)
{
// Repackage the output vectors into individual components. This is
// required because of the format that the quadratic interpolator expects
// for its input data.
Real* afXOutput = new Real[iQuantity];
Real* afYOutput = new Real[iQuantity];
for (int i = 0; i < iQuantity; i++)
{
afXOutput[i] = akOutput[i].X();
afYOutput[i] = akOutput[i].Y();
}
delete[] akOutput;
// Create interpolator for x-coordinate of vector field.
m_pkXInterp = new IntpQdrNonuniform2<Real>(iQuantity,akInput,afXOutput);
// Create interpolator for y-coordinate of vector field, but share the
// already created triangulation for the x-interpolator.
m_pkYInterp = new IntpQdrNonuniform2<Real>(*m_pkXInterp,afYOutput);
}
//----------------------------------------------------------------------------
template <class Real>
IntpVectorField2<Real>::~IntpVectorField2 ()
{
delete m_pkXInterp;
delete m_pkYInterp;
}
//----------------------------------------------------------------------------
template <class Real>
bool IntpVectorField2<Real>::Evaluate (const Vector2<Real>& rkInput,
Vector2<Real>& rkOutput)
{
Real fXDeriv, fYDeriv;
return m_pkXInterp->Evaluate(rkInput,rkOutput.X(),fXDeriv,fYDeriv)
&& m_pkYInterp->Evaluate(rkInput,rkOutput.Y(),fXDeriv,fYDeriv);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// explicit instantiation
//----------------------------------------------------------------------------
namespace Wml
{
template class WML_ITEM IntpVectorField2<float>;
template class WML_ITEM IntpVectorField2<double>;
}
//----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -