 (def normalize (comp (partial apply vec*) (juxt identity (comp (partial / 1.0) magnitude))))
 (defn dot-product [v w] (apply + (map * v w)))
 (defn cross-product [[a b] [c d]] (- (* a d) (* b c)))
-;(defn clamp [v lower upper] (Math/min (Math/max v lower) upper))
+(defn clamp [v lower upper] (Math/min (Math/max v lower) upper))
 (defn angle [v w] (Math/atan2 (cross-product v w) (dot-product v w)))
 (defn rot-cw [[x y]] [y (- x)])
 (defn rot-ccw [[x y]] [(- y) x])
 
 (defn make-node [x y] {:pos [x y] :vel [0 0]})
 (defn make-spring [a b] {:node-a a :node-b b})
-(defn make-hinge [a b c] {:node-a a :node-b b :node-c c})
+(defn make-hinge [a b c min-a max-a] {:node-a a :node-b b :node-c c :min-modifier-angle min-a :max-modifier-angle max-a})
 (defn make-state [nodes springs hinges] {
     :nodes nodes
     :springs (map
         (fn [s] (assoc s
             :rest-length (magnitude (vec- (:pos (nodes (:node-a s))) (:pos (nodes (:node-b s)))))
-            :strength 1000))
+            :strength 2000))
         springs)
     :hinges (map
         (fn [h] (assoc h

(defn calculate-hinge-forces [nodes hinges]
    (apply merge-with vec+
        (map
            (fn [{:keys [node-a node-b node-c rest-angle strength]}] (let [
                [force-a force-c] (calculate-hinge-force (:pos (nodes node-a)) (:pos (nodes node-b)) (:pos (nodes node-c)) rest-angle strength)]
                {
                    node-a force-a
                    node-b (vec- [0 0] force-a force-c)

    {
        :head (make-node 250 150)
        :tail (make-node 50 150)
        :h-l-k (make-node 260 75)
        :h-l-f (make-node 250 0)
        :h-t-k (make-node 260 75)
        :h-t-f (make-node 250 0)
        :t-l-k (make-node 40 75)
        :t-l-f (make-node 50 0)
        :t-t-k (make-node 40 75)
        :t-t-f (make-node 50 0)
    }
    (map (partial apply make-spring) [
        [:head :tail]
