-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rkt
95 lines (77 loc) · 2.86 KB
/
lib.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
; me da pi:
(require scheme/math)
(define 2pi (* 2 pi))
; funcion logistica
(define (logistic x)
(/ 1 (+ 1 (exp (- x)))))
(define (sintime n)
(sin (* n (time))))
(define (costime n)
(cos (* n (time))))
; vectors
(define (vec n) (vector n n n))
(define vec1 (vec 1))
(define vec0 (vec 0))
(define (touch v1 v2 mul)
(vadd v1 (vmul (vector (sin (vector-ref v2 0))
(sin (vector-ref v2 1))
(sin (vector-ref v2 2))) mul)))
(define sndtouch
(case-lambda
[(v1 mul n1 n2 n3)
(vadd v1 (vmul (vector (sin (gh n1))
(sin (gh n2))
(sin (gh n3))) (* 0.1 mul)))]
[(v1 mul)
(sndtouch v1 mul 1 5 9)]))
(define (rtouch v1 mul)
(touch v1 (crndvec) mul))
(define rsndtouch
(case-lambda
[(v1 mul n1 n2 n3)
(touch (sndtouch v1 mul n1 n2 n3) (crndvec) mul)]
[(v1 mul)
(touch (sndtouch v1 mul) (crndvec) mul)]))
; seis direcciones a mod 6:
(define (axismove a speed range)
(vmul (cond
((equal? (fmod a 3) 0.0) (vector (* (sin (* (time) speed)) (- (* 2 (fmod a 2)) 1)) 0 0))
((equal? (fmod a 3) 1.0) (vector 0 (* (sin (* (time) speed)) (- (* 2 (fmod a 2)) 1)) 0))
((equal? (fmod a 3) 2.0) (vector 0 0 (* (sin (* (time) speed)) (- (* 2 (fmod a 2)) 1)))))
range))
(define (axisrotate a speed radio)
(vmul (cond
((equal? (fmod a 3) 0.0) (vector (* (sin (* (time) speed)) (- (* 2 (fmod a 2)) 1))
(* (cos (* (time) speed)) (- (* 2 (fmod a 2)) 1)) 0))
((equal? (fmod a 3) 1.0) (vector 0 (* (sin (* (time) speed)) (- (* 2 (fmod a 2)) 1))
(* (cos (* (time) speed)) (- (* 2 (fmod a 2)) 1))))
((equal? (fmod a 3) 2.0) (vector (* (sin (* (time) speed)) (- (* 2 (fmod a 2)) 1))
0 (* (cos (* (time) speed)) (- (* 2 (fmod a 2)) 1)))))
radio))
(define (grndvecs1 n)
(if (equal? n 0) 'nil
(cons (vector 0 (crndf) (crndf)) (grndvecs1 (- n 1)))))
(define (grndvecs2 n)
(if (equal? n 0) 'nil
(cons (vector (crndf) 0 (crndf)) (grndvecs2 (- n 1)))))
(define (grndvecs3 n)
(if (equal? n 0) 'nil
(cons (vector (crndf) (crndf) 0) (grndvecs3 (- n 1)))))
;====================================
; seno de 0 a 1 x veces por minuto:
(define (beatsin x)
(/ (+ (sin (* (* 2pi (/ x 60.0)) (time))) 1) 2))
; salto de 0 a 1 x veces por minuto:
#;(define (beat x delta)
(if (< (fmod (time) (/ 60 x)) delta)
1
0))
; salto de 0 a 1 x veces por minuto:
(define beat
(case-lambda
[(x) (beat x 0.25)]
[(x delta)
(let ((y (fmod (time) (/ 60 x))))
(if (< y delta)
(sin (* (/ y delta) pi))
0))]))