[英]How to create a sin wave with upper and lower amplitude bounds
I can't for the life of my wrap my head around this seemingly easy problem. 我一生都无法解决这个看似简单的问题。
I am trying to create a sine wave with upper and lower bounds for the amplitude (ie. highest point is 3 and lowest point is 0.4) 我正在尝试创建一个振幅上下限的正弦波(即最高点为3,最低点为0.4)
Using regular math I am able to get a sine wave in an array from 1 to -1 but I don't know how to change those bounds. 使用常规数学,我能够在从1到-1的数组中获得正弦波,但是我不知道如何更改这些界限。
static int MAX_POINTS = 100;
static int CYCLES = 1;
static double[] list = new double[100];
public static void SineCurve()
{
double phaseMultiplier = 2 * Math.PI * CYCLES / MAX_POINTS;
for (int i = 0; i < MAX_POINTS; i++)
{
double cycleX = i * phaseMultiplier;
double sineResult = Math.sin(cycleX);
list[i]= sineResult;
}
for(int i=0;i<list.length;i++){
System.out.println(list[i]);
}
}
Any tips would be greatly appreciated. 任何提示将非常感谢。
The amplitude (multiplier of sin(x) value) is half the difference between the highest and lowest values you want. 幅度(sin(x)值的倍数)是所需的最高值和最低值之差的一半。 In your case
就你而言
amplitude = (3 - 0.4)/2
which is 1.3
. 是
1.3
。 Then zero offset is the lowest value plus the amplitude, which makes it 1.7
in your case. 然后零偏移是最小值加上振幅,在您的情况下为
1.7
。
The equation you want to graph is then 然后要绘制的方程式是
1.3 * sin(x) + 1.7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.