Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Archimedean-spiral/Clojure/archimedean-spiral-1.clj
Normal file
14
Task/Archimedean-spiral/Clojure/archimedean-spiral-1.clj
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(use '(incanter core stats charts io))
|
||||
|
||||
(defn Arquimidean-function
|
||||
[a b theta]
|
||||
(+ a (* theta b)))
|
||||
|
||||
(defn transform-pl-xy [r theta]
|
||||
(let [x (* r (sin theta))
|
||||
y (* r (cos theta))]
|
||||
[x y]))
|
||||
|
||||
(defn arq-spiral [t] (transform-pl-xy (Arquimidean-function 0 7 t) t))
|
||||
|
||||
(view (parametric-plot arq-spiral 0 (* 10 Math/PI)))
|
||||
40
Task/Archimedean-spiral/Clojure/archimedean-spiral-2.clj
Normal file
40
Task/Archimedean-spiral/Clojure/archimedean-spiral-2.clj
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
(let [panel (proxy [javax.swing.JPanel] []
|
||||
(paintComponent [g]
|
||||
(proxy-super paintComponent g)
|
||||
(.setStroke g (java.awt.BasicStroke. 2))
|
||||
(.setRenderingHint g java.awt.RenderingHints/KEY_ANTIALIASING
|
||||
java.awt.RenderingHints/VALUE_ANTIALIAS_ON)
|
||||
(let [[a b] [0 (/ 1 Math/PI)]
|
||||
[w h] [(.getWidth this) (.getHeight this)]
|
||||
[cx cy] [(/ w 2.0) (/ h 2.0)]
|
||||
margin 16
|
||||
[rotations point-n] [3 (quot (min w h) 2)]
|
||||
[ring-n line-n] [6 12]
|
||||
scale (/ (- (min w h) (* 2 margin)) (* 2.0 ring-n))]
|
||||
;; Grid
|
||||
(.setColor g (java.awt.Color. 0xEEEEEE))
|
||||
(doseq [i (range 1 (inc ring-n))]
|
||||
(let [[posx posy] [(- cx (* i scale)) (- cy (* i scale))]]
|
||||
(.drawOval g posx posy (* 2 i scale) (* 2 i scale))))
|
||||
(dotimes [i line-n]
|
||||
(let [theta (* 2 Math/PI (/ i (double line-n)))
|
||||
[x y] [(+ cx (* scale ring-n (Math/cos theta)))
|
||||
(+ cy (* scale ring-n (Math/sin theta)))]]
|
||||
(.drawLine g cx cy x y)))
|
||||
;; Spiral
|
||||
(.setColor g (java.awt.Color. 0x202020))
|
||||
(loop [i 0 [x y] [(+ cx (* a scale)) cy]]
|
||||
(let [p (/ (inc i) (double point-n))
|
||||
theta (* rotations 2 Math/PI p)
|
||||
r (* scale (+ a (* b theta)))
|
||||
[x1 y1] [(+ cx (* r (Math/cos theta)))
|
||||
(- cy (* r (Math/sin theta)))]]
|
||||
(.drawLine g x y x1 y1)
|
||||
(when (< i (dec point-n)) (recur (inc i) [x1 y1])))))))]
|
||||
(doto (javax.swing.JFrame.)
|
||||
(.add (doto panel
|
||||
(.setPreferredSize (java.awt.Dimension. 640 640))
|
||||
(.setBackground java.awt.Color/white))
|
||||
java.awt.BorderLayout/CENTER)
|
||||
(.pack)
|
||||
(.setVisible true)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue