Reputation: 1
This might be more of a math question rather than a programming question, so feel free to remove if against any rules, or if an insult to anyone's intelligence.
I am generating a wave with time on the Y-axis and phase on the X-axis.
I am stuck at... the phase angle(x-axis) amplitude is not scaling with the size of the window (with unmodified newwin x-axis).
getmaxyx(window, y, x) //Get window size
xLoc = (x/2) + (cos(radiant)*(180/Pi)); //Offset to center, rad to deg
wmove(window, y, xLoc); //Move to xLoc location
waddch(window,ch); //Print char S
wrefresh(window); //Print buffer stored
I'm not too sure what and where to place the scaling factor in the xLoc equation.
*Everything is working fine (waveform/up scroll...etc) just not scaling to window width. Please help!
Thanks, JT
Upvotes: 0
Views: 59
Reputation: 80287
To find X-coordinate of the vertical wave point with phase Fi
measured in radians, centered at x/2:
X(Fi) = x/2 * (1 + cos(Fi)) //round to int if needed
P.S. Use appropriate variable names like Width
and Height
, W, H
for window size to avoid confusion with coordinates
Upvotes: 2