mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Polymorphic clone for CRT Pattern in templates (basically a static_cast for concrete initializations of template class)
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Math
|
||||
/*
|
||||
* Convert to string
|
||||
*/
|
||||
template <class ImplClass> QString CVector3DBase<ImplClass>::stringForConverter() const
|
||||
template <class ImplVector> QString CVector3DBase<ImplVector>::stringForConverter() const
|
||||
{
|
||||
QString s = ("{%1, %2, %3}");
|
||||
s = s.arg(QString::number(this->m_i, 'f')).
|
||||
@@ -28,7 +28,7 @@ template <class ImplClass> QString CVector3DBase<ImplClass>::stringForConverter(
|
||||
/*
|
||||
* Vector to zero
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::setZero()
|
||||
template <class ImplVector> void CVector3DBase<ImplVector>::setZero()
|
||||
{
|
||||
this->fill(0.0);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ template <class ImplClass> void CVector3DBase<ImplClass>::setZero()
|
||||
/*
|
||||
* Vector to zero
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::fill(double value)
|
||||
template <class ImplVector> void CVector3DBase<ImplVector>::fill(double value)
|
||||
{
|
||||
this->m_i = value;
|
||||
this->m_j = value;
|
||||
@@ -46,7 +46,7 @@ template <class ImplClass> void CVector3DBase<ImplClass>::fill(double value)
|
||||
/*
|
||||
* Element
|
||||
*/
|
||||
template <class ImplClass> double CVector3DBase<ImplClass>::getElement(size_t row) const
|
||||
template <class ImplVector> double CVector3DBase<ImplVector>::getElement(size_t row) const
|
||||
{
|
||||
double d;
|
||||
switch (row)
|
||||
@@ -71,7 +71,7 @@ template <class ImplClass> double CVector3DBase<ImplClass>::getElement(size_t ro
|
||||
/*
|
||||
* Set given element
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::setElement(size_t row, double value)
|
||||
template <class ImplVector> void CVector3DBase<ImplVector>::setElement(size_t row, double value)
|
||||
{
|
||||
switch (row)
|
||||
{
|
||||
@@ -94,9 +94,9 @@ template <class ImplClass> void CVector3DBase<ImplClass>::setElement(size_t row,
|
||||
/*
|
||||
* Cross product
|
||||
*/
|
||||
template <class ImplClass> ImplClass CVector3DBase<ImplClass>::crossProduct(const ImplClass &otherVector) const
|
||||
template <class ImplVector> ImplVector CVector3DBase<ImplVector>::crossProduct(const ImplVector &otherVector) const
|
||||
{
|
||||
ImplClass v(otherVector);
|
||||
ImplVector v(otherVector);
|
||||
v.m_i = this->m_j * otherVector.m_k - this->m_k * otherVector.m_j;
|
||||
v.m_j = this->m_k * otherVector.m_i - this->m_i * otherVector.m_k;
|
||||
v.m_k = this->m_i * otherVector.m_j - this->m_j * otherVector.m_i;
|
||||
@@ -106,7 +106,7 @@ template <class ImplClass> ImplClass CVector3DBase<ImplClass>::crossProduct(cons
|
||||
/*
|
||||
* Cross product
|
||||
*/
|
||||
template <class ImplClass> double CVector3DBase<ImplClass>::dotProduct(const ImplClass &otherVector) const
|
||||
template <class ImplVector> double CVector3DBase<ImplVector>::dotProduct(const ImplVector &otherVector) const
|
||||
{
|
||||
return this->m_i * otherVector.m_i + this->m_j * otherVector.m_j + this->m_k * otherVector.m_k;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ template <class ImplClass> double CVector3DBase<ImplClass>::dotProduct(const Imp
|
||||
/*
|
||||
* Multiply with matrix
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::matrixMultiplication(const CMatrix3x3 &matrix)
|
||||
template <class ImplVector> void CVector3DBase<ImplVector>::matrixMultiplication(const CMatrix3x3 &matrix)
|
||||
{
|
||||
CMatrix3x1 m = matrix * (this->toMatrix3x1());
|
||||
this->m_i = m(0, 0);
|
||||
@@ -126,7 +126,7 @@ template <class ImplClass> void CVector3DBase<ImplClass>::matrixMultiplication(c
|
||||
/*
|
||||
* Convert to matrix
|
||||
*/
|
||||
template <class ImplClass> CMatrix3x1 CVector3DBase<ImplClass>::toMatrix3x1() const
|
||||
template <class ImplVector> CMatrix3x1 CVector3DBase<ImplVector>::toMatrix3x1() const
|
||||
{
|
||||
return CMatrix3x1(this->m_i, this->m_j, this->m_k);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user