• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

JApplet drawPolyLine problem

memphis_1220

Limp Gawd
Joined
Aug 28, 2004
Messages
499
Hi. I have a problem with an applet that I am creating. It is an oscilloscope but there is one problem. Here is the section of code:

Code:
x[i]=i*timeSelection + 250; // x-coordinate calculation
y[i]= offsetIn + (int)(voltsSelection*amplitudeValue*Math.sin(frequencyValue*i));

timeSelection is an integer i.e 10, 100, 1000, in order to stretch the wave when the time/div is changed.
offsetIn is just to move the wave vertically to a particular position.
voltsSelection is the same as timeSelection only stretching it vertically.
amplitudeValue is a value obtained from a JSlider.
frequencyValue is a value obtained from a JSlider.

When I compile and run this code, this is what happens:

sinewave.jpg


Does anyone know why this is happening? Also, when I change the frequency, it seems to just revert back to 0 (flat line) and increases a bit and then back again.

I would really appreciate some input.
Thanks
Mike
 
IThe question is, what do YOU expect to see?

Consider this, Math.sin(...) takes RADIANS for it's input argument. Is your frequency value in radians? If you need to convert use Math.toRadians() and Math.toDegrees().
 
Thanks for the reply, but it is now sorted. The timeSelection bit was in the wrong place and the frequency needed to be a double for other features to work.
 
Back
Top