Loading ...
Sorry, an error occurred while loading the content.

38608Re: SINE WAVE

Expand Messages
  • Harmon Vinson
    Jul 6, 2009
      Hello Henrik.
      Here is a slightly altered version of Stefan's SIN() plotting program.
      To change the Y-axis edit the CenterX variable (set to 120 in this program).
      The starting and ending x values are controlled by the startx and endx variables, here -1*PI and 4*PI.
      The xscale and yscale variables convert from real numbers to pixels.

      '-----code start (watch for line wraps)
      nomainwin
      WindowWidth = 700
      WindowHeight = WindowWidth/2

      open "Graph" for graphics_nf_nsb as #m
      #m "trapclose [quit]"

      CenterX = 120
      CenterY = (WindowHeight-40) / 2

      #m "down"
      #m "color lightgray"
      #m "size 1"
      #m "line 0 "; CenterY; " "; WindowWidth; " "; CenterY
      #m "line "; CenterX; " 0 "; CenterX; " "; WindowHeight

      #m "color red"
      #m "size 2"

      PI = acs(-1)
      startx = -1*PI
      endx = 4*PI
      xinterval = (endx-startx)/1000

      Xscale = WindowWidth / (endx - startx)
      Yscale = CenterY - 10

      for i = startx to endx step xinterval
      x = CenterX + i * Xscale
      y = CenterY - sin(i) * Yscale
      #m "set "; x; " "; y
      next i

      #m "flush"
      wait

      [quit]
      close #m
      end
      ----- code ends

      --- In libertybasic@yahoogroups.com, Henrik <henriknilson@...> wrote:
      > Thanks,Could you please clear it how to move the Y axis from
      > the center to the left side.
    • Show all 19 messages in this topic