Initial Commit
This commit is contained in:
164
common/CATMULL.HPP
Normal file
164
common/CATMULL.HPP
Normal file
@@ -0,0 +1,164 @@
|
||||
#ifndef _COMMON_CATMULL_HPP_
|
||||
#define _COMMON_CATMULL_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
|
||||
class FloatPairs
|
||||
{
|
||||
public:
|
||||
FloatPairs(void);
|
||||
FloatPairs(const FloatPairs &someFloatPairs);
|
||||
FloatPairs(double column,double row);
|
||||
virtual ~FloatPairs();
|
||||
FloatPairs &operator=(const FloatPairs &someFloatPairs);
|
||||
WORD operator==(const FloatPairs &someFloatPair)const;
|
||||
double column(void)const;
|
||||
void column(double newColumn);
|
||||
double row(void)const;
|
||||
void row(double newRow);
|
||||
void setPairs(double newColumn,double newRow);
|
||||
void setPairs(int newColumn,int newRow);
|
||||
static int fpmax(int firstVal,int secondVal);
|
||||
static int fpmin(int firstVal,int secondVal);
|
||||
private:
|
||||
double mColumn;
|
||||
double mRow;
|
||||
};
|
||||
|
||||
inline
|
||||
FloatPairs::FloatPairs(void)
|
||||
: mColumn(0.00), mRow(0.00)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs::FloatPairs(const FloatPairs &someFloatPairs)
|
||||
{
|
||||
*this=someFloatPairs;
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs::FloatPairs(double column,double row)
|
||||
: mColumn(column), mRow(row)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs::~FloatPairs()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD FloatPairs::operator==(const FloatPairs &someFloatPair)const
|
||||
{
|
||||
return (mColumn==someFloatPair.mColumn && mRow==someFloatPair.mRow);
|
||||
}
|
||||
|
||||
inline
|
||||
FloatPairs &FloatPairs::operator=(const FloatPairs &someFloatPairs)
|
||||
{
|
||||
column(someFloatPairs.column());
|
||||
row(someFloatPairs.row());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
double FloatPairs::column(void)const
|
||||
{
|
||||
return mColumn;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::column(double newColumn)
|
||||
{
|
||||
mColumn=newColumn;
|
||||
}
|
||||
|
||||
inline
|
||||
double FloatPairs::row(void)const
|
||||
{
|
||||
return mRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::row(double newRow)
|
||||
{
|
||||
mRow=newRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::setPairs(double newColumn,double newRow)
|
||||
{
|
||||
mColumn=newColumn;
|
||||
mRow=newRow;
|
||||
}
|
||||
|
||||
inline
|
||||
void FloatPairs::setPairs(int newColumn,int newRow)
|
||||
{
|
||||
mColumn=(double)newColumn;
|
||||
mRow=(double)newRow;
|
||||
}
|
||||
|
||||
inline
|
||||
int FloatPairs::fpmax(int firstVal,int secondVal)
|
||||
{
|
||||
return (firstVal>secondVal?firstVal:secondVal);
|
||||
}
|
||||
|
||||
inline
|
||||
int FloatPairs::fpmin(int firstVal,int secondVal)
|
||||
{
|
||||
return (firstVal<secondVal?firstVal:secondVal);
|
||||
}
|
||||
|
||||
// Sample usage of the spline generator...
|
||||
// CarmullRom splineGen;
|
||||
// Array<FloatPairs> srcPairs;
|
||||
// Array<FloatPairs> dstPairs;
|
||||
// srcPairs[0]=FloatPairs(1.00,25);
|
||||
// srcPairs[1]=FloatPairs(4.00,50);
|
||||
// dstPairs[0]=FloatPairs(1.00,0.00);
|
||||
// dstPairs[1]=FloatPairs(2.00,0.00);
|
||||
// dstPairs[2]=FloatPairs(3.00,0.00);
|
||||
// dstPairs[3]=FloatPairs(4.00,0.00);
|
||||
// splineGen.performSpline(srcPairs,dstPairs);
|
||||
// ... dstPairs contains interpolation of 25-50 across four points
|
||||
|
||||
class CatmullRom
|
||||
{
|
||||
public:
|
||||
CatmullRom(void);
|
||||
virtual ~CatmullRom();
|
||||
WORD performSpline(Array<FloatPairs> &sourcePoints,Array<FloatPairs> &destPoints);
|
||||
private:
|
||||
CatmullRom(const CatmullRom &someCatmullRom);
|
||||
CatmullRom &operator=(const CatmullRom &someCatmullRom);
|
||||
};
|
||||
|
||||
inline
|
||||
CatmullRom::CatmullRom(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CatmullRom::CatmullRom(const CatmullRom &someCatmullRom)
|
||||
{ // no implementation
|
||||
*this=someCatmullRom;
|
||||
}
|
||||
|
||||
inline
|
||||
CatmullRom::~CatmullRom()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
CatmullRom &CatmullRom::operator=(const CatmullRom &/*someCatmullRom*/)
|
||||
{ // no implementation
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user