Changeset 1796


Ignore:
Timestamp:
Aug 23, 2012, 4:05:03 PM (8 years ago)
Author:
sam
Message:

math: add dot() for quaternions, plus the relevant unit test.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/vector.h

    r1513 r1796  
    12181218    \
    12191219    DECLARE_VECTOR_VECTOR_BOOLOP(tname, ==, ==, true, tprefix, t1, t2) \
    1220     DECLARE_VECTOR_VECTOR_BOOLOP(tname, !=, ==, false, tprefix, t1, t2)
    1221 
    1222 #define DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
    1223     DECLARE_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \
     1220    DECLARE_VECTOR_VECTOR_BOOLOP(tname, !=, ==, false, tprefix, t1, t2) \
    12241221    \
    12251222    tprefix \
     
    12311228        return ret; \
    12321229    }
     1230
     1231#define DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
     1232    DECLARE_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf)
    12331233
    12341234#define DECLARE_VEC_3_COERCE_OPS(tname, tprefix, t1, t2, tf) \
     
    13551355
    13561356/* Hack for compilation speedups: we can hide some of our global methods in
    1357  * namespaces. We therefore want "long_double" to be a one-symbol type */
     1357 * namespaces. We therefore want "long_double" to be a single-word name */
    13581358typedef long double long_double;
    13591359
  • trunk/test/unit/quat.cpp

    r1341 r1796  
    7878
    7979        LOLUNIT_ASSERT_EQUAL(norm(a * d), norm(a) * norm(d));
     80    }
     81
     82    LOLUNIT_TEST(Dot)
     83    {
     84        quat a(-1.f, 2.f, -3.f, 4.f);
     85        quat b(8.f, 7.f, 6.f, 5.f);
     86
     87        LOLUNIT_ASSERT_EQUAL(dot(a, b), 8.f);
    8088    }
    8189
Note: See TracChangeset for help on using the changeset viewer.