You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB
C++

/*
* VectorSpinner.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/VectorSpinner.h"
namespace SYSCTRL
{
//CONSTRUCTOR
VectorSpinner::VectorSpinner()
{}//CONSTRUCTOR
//
#pragma CODE_SECTION("ramfuncs");
void VectorSpinner::spin_calculator(SYSCTRL::ProjectionAnalogSignalStructure& projection, SYSCTRL::VecorModuleStructure& module, SYSCTRL::ProjectionAnalogSignalStructure& spinner)
{
module.module = sqrtf(projection.active * projection.active + projection.reactive * projection.reactive);
if(module.module > FP_ZERO)
{
module.reciprocal = 1.0/module.module;
//
spinner.active = module.reciprocal * projection.active;
spinner.reactive = -module.reciprocal * projection.reactive;
//
}
else
{
spinner.active = 1.0;
spinner.reactive = FP_ZERO;
//
};//if else
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void VectorSpinner::spin_reset(SYSCTRL::ProjectionAnalogSignalStructure& spinner)
{
spinner.active = 1.0;
spinner.reactive = FP_ZERO;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void VectorSpinner::ort_corrector(SYSCTRL::ProjectionAnalogSignalStructure& spinner, SYSCTRL::VectorOrthogonalProjection& ort, SYSCTRL::VectorOrthogonalProjection& twisted)
{
twisted.active = spinner.active * ort.active + spinner.reactive * ort.reactive;
twisted.reactive = -spinner.reactive * ort.active + spinner.active * ort.reactive;
//
}//
//
} /* namespace SYSCTRL */