@@ -64,6 +64,37 @@ func TestQuat2Invert(t *testing.T) {
6464}
6565}
6666
67+ func TestQuat2SetReal (t * testing.T ) {
68+ quat2A := []float64 {
69+ 1 , 2 , 3 , 4 ,
70+ 2 , 5 , 6 , - 2 ,
71+ }
72+ actual := Quat2SetReal (quat2A , []float64 {4 , 6 , 8 , - 100 })
73+ expect := []float64 {4 , 6 , 8 , - 100 , 2 , 5 , 6 , - 2 }
74+ if ! testSlice (actual , expect ) {
75+ t .Errorf ("set real: %v" , actual )
76+ }
77+ }
78+ func TestQuat2SetDual (t * testing.T ) {
79+ quat2A := []float64 {
80+ 1 , 2 , 3 , 4 ,
81+ 2 , 5 , 6 , - 2 ,
82+ }
83+ actual := Quat2SetDual (quat2A , []float64 {4.3 , 6 , 8 , - 100 })
84+ expect := []float64 {1 , 2 , 3 , 4 , 4.3 , 6 , 8 , - 100 }
85+ if ! testSlice (actual , expect ) {
86+ t .Errorf ("set dual: %v" , actual )
87+ }
88+ }
89+
90+ func TestQuat2Conjugate (t * testing.T ) {
91+ actual := Quat2Conjugate (Quat2Create (), quat2A )
92+ expect := []float64 {- 1 , - 2 , - 3 , 4 , - 2 , - 5 , - 6 , - 2 }
93+ if ! testSlice (actual , expect ) {
94+ t .Errorf ("conjugate: %v" , actual )
95+ }
96+ }
97+
6798func TestQuat2Multiply (t * testing.T ) {
6899actual := Quat2Create ()
69100Quat2Multiply (actual , quat2A , quat2B )
@@ -76,6 +107,14 @@ func TestQuat2Multiply(t *testing.T) {
76107}
77108}
78109
110+ func TestQuat2Lerp (t * testing.T ) {
111+ actual := Quat2Lerp (Quat2Create (), quat2A , quat2B , 0.7 )
112+ expect := []float64 {3.8 , 4.8 , 5.8 , 6.8 , 6.9 , 7.1 , 6.0 , - 3.4 }
113+ if ! testSlice (actual , expect ) {
114+ t .Errorf ("lerp: %v" , actual )
115+ }
116+ }
117+
79118func TestQuat2Translate (t * testing.T ) {
80119quat2A := Quat2Normalize (Quat2Create (), quat2A )
81120matrixA := Mat4FromQuat2 (Mat4Create (), quat2A )
@@ -100,6 +139,19 @@ func TestQuat2Scale(t *testing.T) {
100139}
101140}
102141
142+ func TestQuat2Length (t * testing.T ) {
143+ actual := Quat2Length (quat2A )
144+ expect := 5.477225
145+ if ! equals (actual , expect ) {
146+ t .Errorf ("length: %v" , actual )
147+ }
148+
149+ actual = Quat2Len (quat2A )
150+ if ! equals (actual , expect ) {
151+ t .Errorf ("len: %v" , actual )
152+ }
153+ }
154+
103155/*
104156func TestQuat2RotateX(t *testing.T) {
105157quat2A := Quat2Normalize(Quat2Create(), quat2A)
@@ -142,6 +194,14 @@ func TestQuat2RotateZ(t *testing.T) {
142194}
143195*/
144196
197+ func TestQuat2FromRotationTranslationValues (t * testing.T ) {
198+ actual := Quat2FromRotationTranslationValues (1 , 2 , 3 , 4 , 1 , 2 , 3 )
199+ expect := []float64 {1 , 2 , 3 , 4 , 2 , 4 , 6 , - 7 }
200+ if ! testSlice (actual , expect ) {
201+ t .Errorf ("from rotation toranslation values: %v" , actual )
202+ }
203+ }
204+
145205func TestQuat2GetTranslation (t * testing.T ) {
146206quat2A := Quat2FromTranslation (Quat2Create (), []float64 {1 , 2 , 3 })
147207actual := Quat2GetTranslation (Vec3Create (), quat2A )
0 commit comments