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

50 lines
1.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Signal_Generator
{
class SinusoidalSignal : IAnalogSignal
{
public string typeToString
{
get
{
return "SIN сигнал";
}
}
public string paramsToString
{
get
{
string result = "";
foreach (KeyValuePair<string, double> pair in paramsDict)
result += " / " + pair.Key + " " + pair.Value;
return result;
}
}
public Dictionary<String, Double> paramsDict { get; set; }
public override string ToString()
{
return "SIN signal";
}
public SinusoidalSignal(double ampl, double freq, double phase = 0)
{
paramsDict = new Dictionary<string, double>();
paramsDict.Add("Амплитуда", ampl);
paramsDict.Add("Частота", freq);
paramsDict.Add("Фаза", phase);
}
public double currentAmplitude(double t)
{
return paramsDict.ElementAt(0).Value * Math.Sin(2 * Math.PI * paramsDict.ElementAt(1).Value * t + paramsDict.ElementAt(2).Value);
}
}
}