Carp/examples/vector.carp
2019-03-22 20:33:06 +01:00

16 lines
565 B
Plaintext

(load "core/Vector.carp") ;; specified path to avoid loading itself on case insensitive file systems
(load "core/Geometry.carp")
(use-all IO Vector2 Geometry)
(defn main []
(let [x (Vector2.init 1.0 2.0)
y (Vector2.init 3.0 4.0)]
(do
(println &(str &(Vector2.add &x &y)))
(println &(str &x))
(println &(str &y))
(println &(Double.str (Vector2.mag &y)))
(println &(str &(Vector2.rotate &x (Geometry.degree-to-radians 90.0))))
(println &(Double.str (Geometry.radians-to-degree (Vector2.angle-between &x &y)))))))