Draw/Plot Sine Function

#! /usr/bin/python3
# ===================================================================
# draw/plot sine function
# ===================================================================

import numpy as np
import draw_axes as ax
import user_interface as ui
import coordinate_conversion as cc
from graphics import *

win = GraphWin("Sine Function", 801, 801)
win.setBackground("white")

ax.draw_xy_axes(win,True)

xstep    = 6
ymax     = 50
deg      = 0.0
deg_step = 180 * (xstep/100)

for cx in range(-400,400,xstep):

    deg = deg % 360.0

    cy = np.sin(np.deg2rad(deg)) * ymax

    (wx,wy) = cc.center_to_win_coords(cx,cy,win.width,win.height)

    ##print(f'[{wx}]  {wy}')

    l = Line(Point(wx,wy),Point(wx+1,wy+1))
    l.setWidth(2)
    l.setFill('black')
    l.draw(win)

    deg += deg_step

ui.pause()

win.close()