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


Groups > comp.lang.python > #72374

Drawing Sinus curve in Python

X-Received by 10.52.4.164 with SMTP id l4mr8979713vdl.3.1401625027542; Sun, 01 Jun 2014 05:17:07 -0700 (PDT)
X-Received by 10.140.96.41 with SMTP id j38mr20070qge.8.1401625027382; Sun, 01 Jun 2014 05:17:07 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!j5no295490qaq.1!news-out.google.com!gi6ni19370igc.0!nntp.google.com!hw13no3364365qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Sun, 1 Jun 2014 05:17:07 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=93.35.218.181; posting-account=WAthVAoAAADGJHhxuRpMeSATf58g0BFe
NNTP-Posting-Host 93.35.218.181
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <c9855239-abca-4753-ad02-2fcf45e56e97@googlegroups.com> (permalink)
Subject Drawing Sinus curve in Python
From Farzad Torabi <seyedfarzad.torabi@gmail.com>
Injection-Date Sun, 01 Jun 2014 12:17:07 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:72374

Show key headers only | 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