Initial
This commit is contained in:
49
engine/SPACIAL.CPP
Normal file
49
engine/SPACIAL.CPP
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <engine/spacial.hpp>
|
||||
#include <common/array.hpp>
|
||||
|
||||
SpacialTransform::~SpacialTransform()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL SpacialTransform::transform(Array<int> &srcVector,Array<int> &dstVector,WORD sizeFactor)
|
||||
{
|
||||
int inverseFactor((100.00/(float)sizeFactor)*100.00);
|
||||
int outSegment(inverseFactor);
|
||||
int inSegment(100);
|
||||
int nextDestIndex(0);
|
||||
int accumulator(0);
|
||||
|
||||
mNextInputIndex=-1;
|
||||
dstVector.size((srcVector.size()*sizeFactor)/100.00);
|
||||
if(!nextInput(srcVector))return FALSE;
|
||||
while(TRUE)
|
||||
{
|
||||
if(outSegment<=inSegment)
|
||||
{
|
||||
accumulator+=((inSegment*mCurrentValue)+((100-inSegment)*mNextValue))*outSegment;
|
||||
inSegment-=outSegment;
|
||||
outSegment=inverseFactor;
|
||||
accumulator*=(float)sizeFactor*.000001;
|
||||
if(nextDestIndex>=dstVector.size())break;
|
||||
dstVector[nextDestIndex++]=accumulator;
|
||||
accumulator=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
accumulator+=((inSegment*mCurrentValue)+((100-inSegment)*mNextValue))*inSegment;
|
||||
outSegment-=inSegment;
|
||||
inSegment=100;
|
||||
if(!nextInput(srcVector))break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL SpacialTransform::nextInput(Array<int> &srcVector)
|
||||
{
|
||||
if(++mNextInputIndex>=srcVector.size())return FALSE;
|
||||
mCurrentValue=srcVector[mNextInputIndex];
|
||||
if(mNextInputIndex+1>=srcVector.size())mNextValue=mCurrentValue;
|
||||
else mNextValue=srcVector[mNextInputIndex+1];
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user