Carp/test/vector3.carp

60 lines
2.0 KiB
Plaintext
Raw Normal View History

(load "Test.carp")
(load "Vector.carp")
(load "Geometry.carp")
2017-12-12 17:08:33 +03:00
(use-all Test Vector3 Geometry Double)
(defn main []
(with-test test
(assert-equal test
&(init 1.0 2.0 3.0) &(init 1.0 2.0 3.0)
2017-11-25 21:19:15 +03:00
"= operator works")
(assert-op test
&(init 1.0 2.0 3.0) &(init 1.0 1.0 3.0)
"/= operator works"
Vector3./=)
(assert-equal test
&(init 3.0 3.0 4.5)
&(+ &(init 2.0 1.0 2.0) &(init 1.0 2.0 2.5))
2017-11-25 21:19:15 +03:00
"+ operator works")
(assert-equal test
&(init 1.0 -1.0 -1.5)
&(- &(init 2.0 1.0 2.0) &(init 1.0 2.0 3.5))
2017-11-25 21:19:15 +03:00
"- operator works")
(assert-equal test
&(init 4.0 2.0 2.2)
&(* &(init 2.0 1.0 1.1) 2.0)
2017-11-25 21:19:15 +03:00
"* operator works")
(assert-equal test
&(init 1.0 0.5 0.25)
&(/ &(init 2.0 1.0 0.5) 2.0)
2017-11-25 21:19:15 +03:00
"/ operator works")
(assert-equal test
5.0
(mag &(init 3.0 4.0 0.0))
2017-11-25 21:19:15 +03:00
"mag works")
(assert-equal test
101.0
(mag-sq &(init 10.0 1.0 0.0))
2017-11-25 21:19:15 +03:00
"mag-sq works")
(assert-equal test
&(init 0.6 0.8 0.0)
&(normalize &(init 3.0 4.0 0.0))
2017-11-25 21:19:15 +03:00
"normalize works")
(assert-op test
90.0
(radians-to-degree (angle-between &(init 1.0 0.0 0.0)
&(init 0.0 1.0 0.0)))
"angle-between works"
Double.approx)
(assert-equal test
53.0
(dot &(init 10.0 2.0 3.0) &(init 2.0 12.0 3.0))
2017-11-25 21:19:15 +03:00
"dot works")
2017-10-24 17:21:38 +03:00
(assert-equal test
&(init 2.5 5.0 0.75)
2017-10-24 17:21:38 +03:00
&(lerp &(init 0.0 0.0 0.5) &(init 5.0 10.0 2.0) 0.5)
2017-11-25 21:19:15 +03:00
"lerp works")
(print-test-results test)
))