Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^3: Make sin wave with GD

by pme (Prior)
on Jul 01, 2015 at 17:25 UTC ( #1132863=note: print w/replies, xml ) Need Help??

in reply to Re^2: Make sin wave with GD
in thread Make sin wave with GD

The 0,0 point is the upper left corner of your 400x400 GD plane if i am not mistaken.

Replies are listed 'Best First'.
Re^4: Make sin wave with GD
by Anonymous Monk on Jul 01, 2015 at 17:40 UTC
    Yes. The wave start in upper left. But I want it to start in middle left. And go up. Not down. Any more help? Thank you again.
      $y2 = 200 - 200*sin($x2));

      The first 200 will shift the center line of the sine so that it is along the center of the plot. The minus sign flips the sine upside down since y is increasing down, not up. Finally, the scale factor is changed to 200 so there is room for both the upper and lower halves of the sine.

      That can be written without repeating the 200 as:

      $y2 = 200 * (1-sin($x2));

        OK that works! Does is there a generic way to do this for any values though?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1132863]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2020-01-21 16:35 GMT
Find Nodes?
    Voting Booth?