Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72374

Drawing Sinus curve in Python

Newsgroups comp.lang.python
Date 2014-06-01 05:17 -0700
Message-ID <c9855239-abca-4753-ad02-2fcf45e56e97@googlegroups.com> (permalink)
Subject Drawing Sinus curve in Python
From Farzad Torabi <seyedfarzad.torabi@gmail.com>

Show all headers | View raw


Hi Experts

 I am trying to draw a sine curve in Python , well first I had a script that i could draw a function curve in this way : 

xMax = 25.0
points = []
for i in range(100):
  x = (float(i)/99)*xMax
  y = math.sqrt(x)
  points.append([x,y])

s.Spline(points=points)


first i have questions that : what does the line x = (float(i)/99)*xMax do ? why do we multiply it by 

and then when I wanted to draw a sine curve I found this one : 

import math

for angle in range(????):
    y = math.sin(math.radians(angle))
    print(y)

first , here instead of ???? can we put 2*pi ?

second i wanted to try this method instead:

xMax = pi
Lamda = 200
points = []
for i in range(Lamda):
  x = (float(i)/99)*xMax
  y = math.sin(x)
  points.append([x,y])

it actually works much better and creates an actual sine curve but the lengths are not really what i want , also if i want to draw a straight line I use this command :

xMax = 1
Lamda = 200
points = []
for i in range(Lamda):
  x = (float(i)/99)
  y = xMax
  points.append([x,y])

but then the problem will be that I can not control the length of this line and the sine curve , that should be equal

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Drawing Sinus curve in Python Farzad Torabi <seyedfarzad.torabi@gmail.com> - 2014-06-01 05:17 -0700
  Re: Drawing Sinus curve in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-01 14:53 +0000
  Re: Drawing Sinus curve in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-01 11:06 -0400

csiph-web