compnent.cpp

来自「这个我写的一个计算LC滤波器的程序」· C++ 代码 · 共 95 行

CPP
95
字号
// Compnent.cpp: implementation of the CCompnent class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Fileter.h"
#include "Compnent.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCompnent::CCompnent()
{
	Value0=0;
}
CCompnent::CCompnent(double value)
{
	Value0=value;
}
CCompnent::~CCompnent()
{

}
CComplex_num CCompnent::GetComplexVal(double frequence)
{
	return CComplex_num(0,Value0);
}

///////////////////////////////////////////////
//THE R COMPNENT
CRCompnent::CRCompnent():CCompnent()
{
}
CRCompnent::CRCompnent(double value):CCompnent(value)
{
}
CComplex_num CRCompnent::GetComplexVal(double Frequence)
{
	return CComplex_num(Value0,0);
}
///////////////////////////////////////////////
//THE C COMPNENT
CCCompnent::CCCompnent():CCompnent()
{
	RValue=1e10;
}

CCCompnent::CCCompnent(double value):CCompnent(value)
{
	RValue=1e10;
}

CCCompnent::CCCompnent(double value,double rval):CCompnent(value)
{
	RValue=rval;
}

CComplex_num CCCompnent::GetComplexVal(double Frequence)
{
	if(Frequence<1.0) Frequence=1;
	if(Value0<1e-17) Value0=1e-17;

	CComplex_num CVal=CComplex_num(0,-1.0/(2*PI*Frequence*Value0));
	CComplex_num RVal=CComplex_num(RValue,0);

	return CVal%RVal;
}
///////////////////////////////////////////////
//THE L COMPNENT
CLCompnent::CLCompnent():CCompnent()
{
	RValue=0;
}
CLCompnent::CLCompnent(double value):CCompnent(value)
{
	RValue=0;
}
CLCompnent::CLCompnent(double value,double Rval):CCompnent(value)
{
	Value0=value;
	RValue=Rval;
}

CComplex_num CLCompnent::GetComplexVal(double Frequence)
{
	return CComplex_num(RValue,2*PI*Frequence*Value0);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?