Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Animate-a-pendulum/Racket/animate-a-pendulum.rkt
Normal file
19
Task/Animate-a-pendulum/Racket/animate-a-pendulum.rkt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#lang racket
|
||||
|
||||
(require 2htdp/image 2htdp/universe)
|
||||
|
||||
(define (pendulum)
|
||||
(define (accel θ) (- (sin θ)))
|
||||
(define θ (/ pi 2.5))
|
||||
(define θ′ 0)
|
||||
(define θ′′ (accel (/ pi 2.5)))
|
||||
(define (x θ) (+ 200 (* 150 (sin θ))))
|
||||
(define (y θ) (* 150 (cos θ)))
|
||||
(λ (n)
|
||||
(define p-image (underlay/xy (add-line (empty-scene 400 200) 200 0 (x θ) (y θ) "black")
|
||||
(- (x θ) 5) (- (y θ) 5) (circle 5 "solid" "blue")))
|
||||
(set! θ (+ θ (* θ′ 0.04)))
|
||||
(set! θ′ (+ θ′ (* (accel θ) 0.04)))
|
||||
p-image))
|
||||
|
||||
(animate (pendulum))
|
||||
Loading…
Add table
Add a link
Reference in a new issue