File: noise.rb

package info (click to toggle)
ctioga 1.10-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,052 kB
  • ctags: 953
  • sloc: ruby: 9,306; sh: 504; makefile: 6
file content (13 lines) | stat: -rw-r--r-- 347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Small script for generating sine and cosine:
# use it this way:
# ruby trig.rb > trig.dat

include Math                    # can come in useful

100.times do |i|
  x = (-1.5 * PI + i * 1.5 * PI / 49.5).to_f
  alea = rand - 0.5
  alea2= rand - 0.5
  signum = (alea>0)?-1:1
  puts "#{signum*x+alea2}\t#{cos(signum*x)}\t#{cos(signum*x+alea2)}"
end