| 1 | |
| 2 | // Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide. |
| 3 | // All rights reserved. |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without modification, |
| 6 | // are permitted provided that the following conditions are met: |
| 7 | // |
| 8 | // 1. Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions, and the following disclaimer. |
| 10 | // |
| 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | // this list of conditions, and the following disclaimer in the documentation |
| 13 | // and/or other materials provided with the distribution. |
| 14 | // |
| 15 | // 3. Neither the names of the copyright holders nor the names of their contributors |
| 16 | // may be used to endorse or promote products derived from this software without |
| 17 | // specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 | // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 24 | // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR |
| 26 | // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS |
| 28 | // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES |
| 29 | // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE |
| 30 | // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES. |
| 31 | // |
| 32 | |
| 33 | #ifndef XSMATRIX3X3_H |
| 34 | #define XSMATRIX3X3_H |
| 35 | |
| 36 | #include "xsmatrix.h" |
| 37 | |
| 38 | struct XsMatrix3x3; |
| 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | #ifndef __cplusplus |
| 43 | typedef struct XsMatrix3x3 XsMatrix3x3; |
| 44 | #endif |
| 45 | |
| 46 | |
| 47 | XSTYPES_DLL_API void XsMatrix3x3_construct(XsMatrix3x3* thisPtr); |
| 48 | XSTYPES_DLL_API void XsMatrix3x3_assign(XsMatrix3x3* thisPtr, const XsReal* src, XsSize srcStride); |
| 49 | XSTYPES_DLL_API void XsMatrix3x3_destruct(XsMatrix3x3* thisPtr); |
| 50 | XSTYPES_DLL_API void XsMatrix3x3_copy(XsMatrix* copy, XsMatrix3x3 const* src); |
| 51 | |
| 52 | #ifdef __cplusplus |
| 53 | } // extern "C" |
| 54 | |
| 55 | /* This is allowed since the C standard says that no padding appears before the first member of a struct. |
| 56 | Basically we're defining a union between a C++ inherited type and a C encapsulated type. |
| 57 | */ |
| 58 | struct XsMatrix3x3 : public XsMatrix { |
| 59 | XSCPPPROTECTED |
| 60 | #endif |
| 61 | #ifndef __cplusplus |
| 62 | struct XsMatrix3x3 { |
| 63 | struct XsMatrix m_matrix; //!< The underlying XsMatrix |
| 64 | #endif |
| 65 | XsReal XSCCONST m_fixedData[9]; //!< Fixed storage for the elements of the matrix |
| 66 | |
| 67 | #ifdef __cplusplus |
| 68 | public: |
| 69 | //! \brief Constructs an XsMatrix3x3 |
| 70 | XsMatrix3x3() : XsMatrix(m_fixedData, 3, 3, 3, XSDF_FixedSize) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | //! \brief Constructs an XsMatrix3x3 from an \a other XsMatrix |
| 75 | XsMatrix3x3(const XsMatrix& other) : XsMatrix(other, m_fixedData, 3, 3, 3, XSDF_FixedSize) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | //! \brief Constructs an XsMatrix3x3 from an \a other XsMatrix |
| 80 | XsMatrix3x3(const XsMatrix3x3& other) : XsMatrix(other, m_fixedData, 3, 3, 3, XSDF_FixedSize) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | //! \brief Constructs an XsMatrix3x3 from a set of values |
| 85 | XsMatrix3x3(XsReal r1c1, XsReal r1c2, XsReal r1c3, |
| 86 | XsReal r2c1, XsReal r2c2, XsReal r2c3, |
| 87 | XsReal r3c1, XsReal r3c2, XsReal r3c3) : XsMatrix(m_fixedData, 3, 3, 3, XSDF_FixedSize) |
| 88 | { |
| 89 | m_fixedData[0] = r1c1; |
| 90 | m_fixedData[1] = r1c2; |
| 91 | m_fixedData[2] = r1c3; |
| 92 | m_fixedData[3] = r2c1; |
| 93 | m_fixedData[4] = r2c2; |
| 94 | m_fixedData[5] = r2c3; |
| 95 | m_fixedData[6] = r3c1; |
| 96 | m_fixedData[7] = r3c2; |
| 97 | m_fixedData[8] = r3c3; |
| 98 | } |
| 99 | // using XsMatrix::operator=; |
| 100 | // using XsMatrix::operator[]; |
| 101 | #endif |
| 102 | }; |
| 103 | #if 0 |
| 104 | } // for Qt lupdate parser |
| 105 | #endif |
| 106 | |
| 107 | #endif |