├── .gitignore ├── LICENSE.md ├── README.md ├── include └── xbb │ ├── Axis.h │ ├── Base.h │ ├── Constancy.h │ ├── ElementAccess.h │ ├── Identity.h │ ├── InverseProvision.h │ ├── Matrix3x3.h │ ├── Matrix4x3.h │ ├── Matrix4x4.h │ ├── MatrixValuesFrom.h │ ├── Multiply.h │ ├── ProxyMatrix.h │ ├── ReducedMatrix.h │ ├── RotationX.h │ ├── RotationY.h │ ├── RotationZ.h │ ├── Scale.h │ ├── Shear3.h │ ├── ShearOf.h │ ├── Transforms.h │ ├── Translation.h │ ├── Transpose.h │ └── detail │ ├── ConstancyAccess.h │ ├── ConstancyByMatrixMultiply.h │ ├── ConstancyThroughAddition.h │ ├── ConstancyThroughMultiplication.h │ ├── ElementMultiplier.h │ ├── ElementProduct.h │ ├── Entry.h │ ├── IsSameType.h │ └── NotConstantIfSheared.h └── unittest ├── AdaptRefToXbb.h ├── AdaptersWork.cpp ├── BasicTransformsMatch.cpp ├── CATCH ├── LICENSE_1_0.txt ├── README.md └── catch.hpp ├── EliminateIdentityFromMultiplication.cpp ├── FloatingPointComparisons.h ├── InverseSxSH.cpp ├── InversesMatch.cpp ├── Makefile ├── PartialPrecomputedSxSHxRxT.cpp ├── PrecomputedSxSHxRxT.cpp ├── ScopedTimer.h ├── StandardSxSHxPSxPSHxRxIPSHxIPSxTxP.cpp ├── StandardSxSHxRxT.cpp ├── TestValues.cpp ├── TestValues.h ├── TransformsAreClose.h ├── TypeChecking.cpp ├── main.cpp └── ref ├── Matrix4x4.h └── Vec3.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *~ 4 | *.*~ 5 | testXbb 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Intel Corporation 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 11 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | XForm Building Blocks (XBB) 2 | ------------------------------------------------ 3 | C++11 library to enable composition of 3d transforms 4 | 5 | * Use minimum number of trigonometric operations, multiplications, divisions, and additions 6 | * Take full advantage of known constant's through multiple transform concatenations (multiplications), 7 | * Reverse order of concatenations vs. performing an expensive "inverse". 8 | 9 | For motivation, an introduction, and practical results see [Slashing the Cost of 3d Matrix Math using X-Form (Transform) Building Blocks] 10 | 11 | [Slashing the Cost of 3d Matrix Math using X-Form (Transform) Building Blocks]:http://www.slideshare.net/IntelSoftware/dreamworks-animation-51882186 12 | -------------------------------------------------------------------------------- /include/xbb/Axis.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_AXIS_H 29 | #define XBB_AXIS_H 30 | 31 | namespace xbb { 32 | 33 | enum Axis { 34 | AxisX = 0, 35 | AxisY = 1, 36 | AxisZ = 2 37 | }; 38 | } // namespace xbb 39 | 40 | #endif // XBB_CONSTANCY_H 41 | -------------------------------------------------------------------------------- /include/xbb/Constancy.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_CONSTANCY_H 29 | #define XBB_CONSTANCY_H 30 | 31 | namespace xbb { 32 | 33 | enum Constancy { 34 | ConstantZero, 35 | ConstantOne, 36 | NotConstant, 37 | }; 38 | } // namespace xbb 39 | 40 | #endif // XBB_CONSTANCY_H 41 | -------------------------------------------------------------------------------- /include/xbb/ElementAccess.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_ELEMENT_ACCESS_H 29 | #define XBB_ELEMENT_ACCESS_H 30 | 31 | namespace xbb { 32 | 33 | 34 | template 35 | struct ElementAccess 36 | { 37 | template 38 | static double e(const T &iTransform); 39 | }; 40 | 41 | template<> 42 | struct ElementAccess<0,0> 43 | { 44 | template 45 | static double e(const T &iTransform) { return iTransform.e00(); } 46 | }; 47 | 48 | template<> 49 | struct ElementAccess<0,1> 50 | { 51 | template 52 | static double e(const T &iTransform) { return iTransform.e01(); } 53 | }; 54 | 55 | template<> 56 | struct ElementAccess<0,2> 57 | { 58 | template 59 | static double e(const T &iTransform) { return iTransform.e02(); } 60 | }; 61 | 62 | template<> 63 | struct ElementAccess<0,3> 64 | { 65 | template 66 | static double e(const T &iTransform) { return iTransform.e03(); } 67 | }; 68 | 69 | template<> 70 | struct ElementAccess<1,0> 71 | { 72 | template 73 | static double e(const T &iTransform) { return iTransform.e10(); } 74 | }; 75 | 76 | template<> 77 | struct ElementAccess<1,1> 78 | { 79 | template 80 | static double e(const T &iTransform) { return iTransform.e11(); } 81 | }; 82 | 83 | template<> 84 | struct ElementAccess<1,2> 85 | { 86 | template 87 | static double e(const T &iTransform) { return iTransform.e12(); } 88 | }; 89 | 90 | template<> 91 | struct ElementAccess<1,3> 92 | { 93 | template 94 | static double e(const T &iTransform) { return iTransform.e13(); } 95 | }; 96 | 97 | 98 | 99 | template<> 100 | struct ElementAccess<2,0> 101 | { 102 | template 103 | static double e(const T &iTransform) { return iTransform.e20(); } 104 | }; 105 | 106 | template<> 107 | struct ElementAccess<2,1> 108 | { 109 | template 110 | static double e(const T &iTransform) { return iTransform.e21(); } 111 | }; 112 | 113 | template<> 114 | struct ElementAccess<2,2> 115 | { 116 | template 117 | static double e(const T &iTransform) { return iTransform.e22(); } 118 | }; 119 | 120 | template<> 121 | struct ElementAccess<2,3> 122 | { 123 | template 124 | static double e(const T &iTransform) { return iTransform.e23(); } 125 | }; 126 | 127 | 128 | template<> 129 | struct ElementAccess<3,0> 130 | { 131 | template 132 | static double e(const T &iTransform) { return iTransform.e30(); } 133 | }; 134 | 135 | template<> 136 | struct ElementAccess<3,1> 137 | { 138 | template 139 | static double e(const T &iTransform) { return iTransform.e31(); } 140 | }; 141 | 142 | template<> 143 | struct ElementAccess<3,2> 144 | { 145 | template 146 | static double e(const T &iTransform) { return iTransform.e32(); } 147 | }; 148 | 149 | template<> 150 | struct ElementAccess<3,3> 151 | { 152 | template 153 | static double e(const T &iTransform) { return iTransform.e33(); } 154 | }; 155 | 156 | 157 | 158 | 159 | } // namespace xbb 160 | 161 | #endif // XBB_ELEMENT_ACCESS_H 162 | -------------------------------------------------------------------------------- /include/xbb/Identity.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_IDENTITY_H 29 | #define XBB_IDENTITY_H 30 | 31 | #include "Base.h" 32 | 33 | namespace xbb { 34 | 35 | struct Identity : 36 | public Base 37 | { 38 | Identity() 39 | {} 40 | 41 | 42 | static const InverseProvision inverseProvision = InverseProvided; 43 | typedef Identity InverseType; 44 | inline InverseType inverse() const { return Identity(); } 45 | 46 | double e00() const { return 1.0; } 47 | double e01() const { return 0.0; } 48 | double e02() const { return 0.0; } 49 | double e03() const { return 0.0; } 50 | 51 | double e10() const { return 0.0; } 52 | double e11() const { return 1.0; } 53 | double e12() const { return 0.0; } 54 | double e13() const { return 0.0; } 55 | 56 | double e20() const { return 0.0; } 57 | double e21() const { return 0.0; } 58 | double e22() const { return 1.0; } 59 | double e23() const { return 0.0; } 60 | 61 | double e30() const { return 0.0; } 62 | double e31() const { return 0.0; } 63 | double e32() const { return 0.0; } 64 | double e33() const { return 1.0; } 65 | 66 | static const Constancy c00 = ConstantOne; 67 | static const Constancy c01 = ConstantZero; 68 | static const Constancy c02 = ConstantZero; 69 | static const Constancy c03 = ConstantZero; 70 | 71 | static const Constancy c10 = ConstantZero; 72 | static const Constancy c11 = ConstantOne; 73 | static const Constancy c12 = ConstantZero; 74 | static const Constancy c13 = ConstantZero; 75 | 76 | static const Constancy c20 = ConstantZero; 77 | static const Constancy c21 = ConstantZero; 78 | static const Constancy c22 = ConstantOne; 79 | static const Constancy c23 = ConstantZero; 80 | 81 | static const Constancy c30 = ConstantZero; 82 | static const Constancy c31 = ConstantZero; 83 | static const Constancy c32 = ConstantZero; 84 | static const Constancy c33 = ConstantOne; 85 | 86 | 87 | // Identity multiplied by any other Transform 88 | // is just the other Transform 89 | // NOTE: return type is new instance vs. 90 | // a const & to enable predictable results when used inside of 91 | // decltype() for templates. 92 | // Performance should not suffer due to 93 | // return value optimization 94 | template 95 | OtherT 96 | operator*(const OtherT &aOther) const 97 | { 98 | return aOther; 99 | } 100 | 101 | }; 102 | } // namespace xbb 103 | 104 | #endif // XBB_IDENTITY_H 105 | -------------------------------------------------------------------------------- /include/xbb/InverseProvision.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_INVERSE_PROVISION_H 29 | #define XBB_INVERSE_PROVISION_H 30 | 31 | namespace xbb { 32 | 33 | enum InverseProvision { 34 | InverseDeprived, 35 | InverseProvided 36 | }; 37 | 38 | } // namespace xbb 39 | 40 | #endif // XBB_INVERSE_PROVISION_H 41 | -------------------------------------------------------------------------------- /include/xbb/Matrix3x3.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_MATRIX_3_X_3_H 29 | #define XBB_MATRIX_3_X_3_H 30 | 31 | #include "Base.h" 32 | #include "MatrixValuesFrom.h" 33 | 34 | 35 | namespace xbb { 36 | 37 | struct Matrix3x3 : 38 | public Base 39 | { 40 | Matrix3x3() 41 | { 42 | // uninitialized 43 | } 44 | Matrix3x3( 45 | double i00, double i01, double i02, 46 | double i10, double i11, double i12, 47 | double i20, double i21, double i22) 48 | : m00(i00) 49 | , m01(i01) 50 | , m02(i02) 51 | , m10(i10) 52 | , m11(i11) 53 | , m12(i12) 54 | , m20(i20) 55 | , m21(i21) 56 | , m22(i22) 57 | {} 58 | 59 | template 60 | Matrix3x3(const UserTypeT &iValue) 61 | : m00(MatrixValuesFrom::e00(iValue)) 62 | , m01(MatrixValuesFrom::e01(iValue)) 63 | , m02(MatrixValuesFrom::e02(iValue)) 64 | , m10(MatrixValuesFrom::e10(iValue)) 65 | , m11(MatrixValuesFrom::e11(iValue)) 66 | , m12(MatrixValuesFrom::e12(iValue)) 67 | , m20(MatrixValuesFrom::e20(iValue)) 68 | , m21(MatrixValuesFrom::e21(iValue)) 69 | , m22(MatrixValuesFrom::e22(iValue)) 70 | {} 71 | 72 | static const InverseProvision inverseProvision = InverseDeprived; 73 | 74 | // Column # Row # 75 | double m00; 76 | double m01; 77 | double m02; 78 | 79 | double m10; 80 | double m11; 81 | double m12; 82 | 83 | double m20; 84 | double m21; 85 | double m22; 86 | 87 | double e00() const { return m00; } 88 | double e01() const { return m01; } 89 | double e02() const { return m02; } 90 | double e03() const { return 0.0; } 91 | 92 | double e10() const { return m10; } 93 | double e11() const { return m11; } 94 | double e12() const { return m12; } 95 | double e13() const { return 0.0; } 96 | 97 | double e20() const { return m20; } 98 | double e21() const { return m21; } 99 | double e22() const { return m22; } 100 | double e23() const { return 0.0; } 101 | 102 | double e30() const { return 0.0; } 103 | double e31() const { return 0.0; } 104 | double e32() const { return 0.0; } 105 | double e33() const { return 1.0; } 106 | 107 | static const Constancy c00 = NotConstant; 108 | static const Constancy c01 = NotConstant; 109 | static const Constancy c02 = NotConstant; 110 | static const Constancy c03 = ConstantZero; 111 | 112 | static const Constancy c10 = NotConstant; 113 | static const Constancy c11 = NotConstant; 114 | static const Constancy c12 = NotConstant; 115 | static const Constancy c13 = ConstantZero; 116 | 117 | static const Constancy c20 = NotConstant; 118 | static const Constancy c21 = NotConstant; 119 | static const Constancy c22 = NotConstant; 120 | static const Constancy c23 = ConstantZero; 121 | 122 | static const Constancy c30 = ConstantZero; 123 | static const Constancy c31 = ConstantZero; 124 | static const Constancy c32 = ConstantZero; 125 | static const Constancy c33 = ConstantOne; 126 | 127 | }; 128 | 129 | template <> 130 | struct MatrixValuesTo 131 | { 132 | static void e00(Matrix3x3 & iTo, double iValue) 133 | { 134 | iTo.m00 = iValue; 135 | } 136 | static void e01(Matrix3x3 & iTo, double iValue) 137 | { 138 | iTo.m01 = iValue; 139 | } 140 | static void e02(Matrix3x3 & iTo, double iValue) 141 | { 142 | iTo.m02 = iValue; 143 | } 144 | 145 | static void e03(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 146 | { 147 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 148 | } 149 | 150 | static void e10(Matrix3x3 & iTo, double iValue) 151 | { 152 | iTo.m10 = iValue; 153 | } 154 | static void e11(Matrix3x3 & iTo, double iValue) 155 | { 156 | iTo.m11 = iValue; 157 | } 158 | static void e12(Matrix3x3 & iTo, double iValue) 159 | { 160 | iTo.m12 = iValue; 161 | } 162 | 163 | static void e13(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 164 | { 165 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 166 | } 167 | 168 | static void e20(Matrix3x3 & iTo, double iValue) 169 | { 170 | iTo.m20= iValue; 171 | } 172 | static void e21(Matrix3x3 & iTo, double iValue) 173 | { 174 | iTo.m21 = iValue; 175 | } 176 | static void e22(Matrix3x3 & iTo, double iValue) 177 | { 178 | iTo.m22 = iValue; 179 | } 180 | 181 | static void e23(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 182 | { 183 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 184 | } 185 | 186 | static void e30(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 187 | { 188 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 189 | } 190 | static void e31(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 191 | { 192 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 193 | } 194 | static void e32(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 195 | { 196 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 197 | } 198 | static void e33(Matrix3x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 199 | { 200 | XBB_ASSERT(!(iValue > 1.0) && !(iValue < 1.0)); 201 | } 202 | }; 203 | 204 | } // namespace xbb 205 | 206 | 207 | #endif // XBB_MATRIX_3_X_3_H 208 | -------------------------------------------------------------------------------- /include/xbb/Matrix4x3.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_MATRIX_4_X_3_H 29 | #define XBB_MATRIX_4_X_3_H 30 | 31 | #include "Base.h" 32 | #include "MatrixValuesFrom.h" 33 | 34 | 35 | namespace xbb { 36 | 37 | struct Matrix4x3 : 38 | public Base 39 | { 40 | Matrix4x3() 41 | { 42 | // uninitialized 43 | } 44 | Matrix4x3( 45 | double i00, double i01, double i02, 46 | double i10, double i11, double i12, 47 | double i20, double i21, double i22, 48 | double i30, double i31, double i32) 49 | : m00(i00) 50 | , m01(i01) 51 | , m02(i02) 52 | , m10(i10) 53 | , m11(i11) 54 | , m12(i12) 55 | , m20(i20) 56 | , m21(i21) 57 | , m22(i22) 58 | , m30(i30) 59 | , m31(i31) 60 | , m32(i32) 61 | {} 62 | 63 | template 64 | Matrix4x3(const UserTypeT &iValue) 65 | : m00(MatrixValuesFrom::e00(iValue)) 66 | , m01(MatrixValuesFrom::e01(iValue)) 67 | , m02(MatrixValuesFrom::e02(iValue)) 68 | , m10(MatrixValuesFrom::e10(iValue)) 69 | , m11(MatrixValuesFrom::e11(iValue)) 70 | , m12(MatrixValuesFrom::e12(iValue)) 71 | , m20(MatrixValuesFrom::e20(iValue)) 72 | , m21(MatrixValuesFrom::e21(iValue)) 73 | , m22(MatrixValuesFrom::e22(iValue)) 74 | , m30(MatrixValuesFrom::e30(iValue)) 75 | , m31(MatrixValuesFrom::e31(iValue)) 76 | , m32(MatrixValuesFrom::e32(iValue)) 77 | {} 78 | 79 | static const InverseProvision inverseProvision = InverseDeprived; 80 | 81 | // Column # Row # 82 | double m00; 83 | double m01; 84 | double m02; 85 | 86 | double m10; 87 | double m11; 88 | double m12; 89 | 90 | double m20; 91 | double m21; 92 | double m22; 93 | 94 | double m30; 95 | double m31; 96 | double m32; 97 | 98 | 99 | double e00() const { return m00; } 100 | double e01() const { return m01; } 101 | double e02() const { return m02; } 102 | double e03() const { return 0.0; } 103 | 104 | double e10() const { return m10; } 105 | double e11() const { return m11; } 106 | double e12() const { return m12; } 107 | double e13() const { return 0.0; } 108 | 109 | double e20() const { return m20; } 110 | double e21() const { return m21; } 111 | double e22() const { return m22; } 112 | double e23() const { return 0.0; } 113 | 114 | double e30() const { return m30; } 115 | double e31() const { return m31; } 116 | double e32() const { return m32; } 117 | double e33() const { return 1.0; } 118 | 119 | static const Constancy c00 = NotConstant; 120 | static const Constancy c01 = NotConstant; 121 | static const Constancy c02 = NotConstant; 122 | static const Constancy c03 = ConstantZero; 123 | 124 | static const Constancy c10 = NotConstant; 125 | static const Constancy c11 = NotConstant; 126 | static const Constancy c12 = NotConstant; 127 | static const Constancy c13 = ConstantZero; 128 | 129 | static const Constancy c20 = NotConstant; 130 | static const Constancy c21 = NotConstant; 131 | static const Constancy c22 = NotConstant; 132 | static const Constancy c23 = ConstantZero; 133 | 134 | static const Constancy c30 = NotConstant; 135 | static const Constancy c31 = NotConstant; 136 | static const Constancy c32 = NotConstant; 137 | static const Constancy c33 = ConstantOne; 138 | }; 139 | 140 | 141 | template <> 142 | struct MatrixValuesTo 143 | { 144 | static void e00(Matrix4x3 & iTo, double iValue) 145 | { 146 | iTo.m00 = iValue; 147 | } 148 | static void e01(Matrix4x3 & iTo, double iValue) 149 | { 150 | iTo.m01 = iValue; 151 | } 152 | static void e02(Matrix4x3 & iTo, double iValue) 153 | { 154 | iTo.m02 = iValue; 155 | } 156 | 157 | static void e03(Matrix4x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 158 | { 159 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 160 | } 161 | 162 | static void e10(Matrix4x3 & iTo, double iValue) 163 | { 164 | iTo.m10 = iValue; 165 | } 166 | static void e11(Matrix4x3 & iTo, double iValue) 167 | { 168 | iTo.m11 = iValue; 169 | } 170 | static void e12(Matrix4x3 & iTo, double iValue) 171 | { 172 | iTo.m12 = iValue; 173 | } 174 | 175 | static void e13(Matrix4x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 176 | { 177 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 178 | } 179 | 180 | static void e20(Matrix4x3 & iTo, double iValue) 181 | { 182 | iTo.m20= iValue; 183 | } 184 | static void e21(Matrix4x3 & iTo, double iValue) 185 | { 186 | iTo.m21 = iValue; 187 | } 188 | static void e22(Matrix4x3 & iTo, double iValue) 189 | { 190 | iTo.m22 = iValue; 191 | } 192 | 193 | static void e23(Matrix4x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 194 | { 195 | XBB_ASSERT(!(iValue > 0.0) && !(iValue < 0.0)); 196 | } 197 | 198 | static void e30(Matrix4x3 & iTo, double iValue) 199 | { 200 | iTo.m30 = iValue; 201 | } 202 | static void e31(Matrix4x3 & iTo, double iValue) 203 | { 204 | iTo.m31 = iValue; 205 | } 206 | static void e32(Matrix4x3 & iTo, double iValue) 207 | { 208 | iTo.m32 = iValue; 209 | } 210 | static void e33(Matrix4x3 & /*iTo*/, double XBB_DEBUG_ONLY_VAR(iValue)) 211 | { 212 | XBB_ASSERT(!(iValue > 1.0) && !(iValue < 1.0)); 213 | } 214 | }; 215 | 216 | } // namespace xbb 217 | 218 | 219 | #endif // XBB_MATRIX_4_X_3_H 220 | -------------------------------------------------------------------------------- /include/xbb/Matrix4x4.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_MATRIX_4_X_4_H 29 | #define XBB_MATRIX_4_X_4_H 30 | 31 | #include "Base.h" 32 | #include "MatrixValuesFrom.h" 33 | 34 | 35 | namespace xbb { 36 | 37 | struct Matrix4x4 : 38 | public Base 39 | { 40 | Matrix4x4() 41 | { 42 | // uninitialized 43 | } 44 | Matrix4x4( 45 | double i00, double i01, double i02, double i03, 46 | double i10, double i11, double i12, double i13, 47 | double i20, double i21, double i22, double i23, 48 | double i30, double i31, double i32, double i33) 49 | : m00(i00) 50 | , m01(i01) 51 | , m02(i02) 52 | , m03(i03) 53 | , m10(i10) 54 | , m11(i11) 55 | , m12(i12) 56 | , m13(i13) 57 | , m20(i20) 58 | , m21(i21) 59 | , m22(i22) 60 | , m23(i23) 61 | , m30(i30) 62 | , m31(i31) 63 | , m32(i32) 64 | , m33(i33) 65 | {} 66 | 67 | template 68 | Matrix4x4(const UserTypeT &iValue) 69 | : m00(MatrixValuesFrom::e00(iValue)) 70 | , m01(MatrixValuesFrom::e01(iValue)) 71 | , m02(MatrixValuesFrom::e02(iValue)) 72 | , m03(MatrixValuesFrom::e03(iValue)) 73 | , m10(MatrixValuesFrom::e10(iValue)) 74 | , m11(MatrixValuesFrom::e11(iValue)) 75 | , m12(MatrixValuesFrom::e12(iValue)) 76 | , m13(MatrixValuesFrom::e13(iValue)) 77 | , m20(MatrixValuesFrom::e20(iValue)) 78 | , m21(MatrixValuesFrom::e21(iValue)) 79 | , m22(MatrixValuesFrom::e22(iValue)) 80 | , m23(MatrixValuesFrom::e23(iValue)) 81 | , m30(MatrixValuesFrom::e30(iValue)) 82 | , m31(MatrixValuesFrom::e31(iValue)) 83 | , m32(MatrixValuesFrom::e32(iValue)) 84 | , m33(MatrixValuesFrom::e33(iValue)) 85 | {} 86 | 87 | static const InverseProvision inverseProvision = InverseDeprived; 88 | 89 | // Column # Row # 90 | double m00; 91 | double m01; 92 | double m02; 93 | double m03; 94 | 95 | double m10; 96 | double m11; 97 | double m12; 98 | double m13; 99 | 100 | double m20; 101 | double m21; 102 | double m22; 103 | double m23; 104 | 105 | double m30; 106 | double m31; 107 | double m32; 108 | double m33; 109 | 110 | 111 | double e00() const { return m00; } 112 | double e01() const { return m01; } 113 | double e02() const { return m02; } 114 | double e03() const { return m03; } 115 | 116 | double e10() const { return m10; } 117 | double e11() const { return m11; } 118 | double e12() const { return m12; } 119 | double e13() const { return m13; } 120 | 121 | double e20() const { return m20; } 122 | double e21() const { return m21; } 123 | double e22() const { return m22; } 124 | double e23() const { return m23; } 125 | 126 | double e30() const { return m30; } 127 | double e31() const { return m31; } 128 | double e32() const { return m32; } 129 | double e33() const { return m33; } 130 | 131 | static const Constancy c00 = NotConstant; 132 | static const Constancy c01 = NotConstant; 133 | static const Constancy c02 = NotConstant; 134 | static const Constancy c03 = NotConstant; 135 | 136 | static const Constancy c10 = NotConstant; 137 | static const Constancy c11 = NotConstant; 138 | static const Constancy c12 = NotConstant; 139 | static const Constancy c13 = NotConstant; 140 | 141 | static const Constancy c20 = NotConstant; 142 | static const Constancy c21 = NotConstant; 143 | static const Constancy c22 = NotConstant; 144 | static const Constancy c23 = NotConstant; 145 | 146 | static const Constancy c30 = NotConstant; 147 | static const Constancy c31 = NotConstant; 148 | static const Constancy c32 = NotConstant; 149 | static const Constancy c33 = NotConstant; 150 | }; 151 | 152 | 153 | template <> 154 | struct MatrixValuesTo 155 | { 156 | static void e00(Matrix4x4 & iTo, double iValue) 157 | { 158 | iTo.m00 = iValue; 159 | } 160 | static void e01(Matrix4x4 & iTo, double iValue) 161 | { 162 | iTo.m01 = iValue; 163 | } 164 | static void e02(Matrix4x4 & iTo, double iValue) 165 | { 166 | iTo.m02 = iValue; 167 | } 168 | 169 | static void e03(Matrix4x4 & iTo, double iValue) 170 | { 171 | iTo.m03 = iValue; 172 | } 173 | 174 | static void e10(Matrix4x4 & iTo, double iValue) 175 | { 176 | iTo.m10 = iValue; 177 | } 178 | static void e11(Matrix4x4 & iTo, double iValue) 179 | { 180 | iTo.m11 = iValue; 181 | } 182 | static void e12(Matrix4x4 & iTo, double iValue) 183 | { 184 | iTo.m12 = iValue; 185 | } 186 | 187 | static void e13(Matrix4x4 & iTo, double iValue) 188 | { 189 | iTo.m13 = iValue; 190 | } 191 | 192 | static void e20(Matrix4x4 & iTo, double iValue) 193 | { 194 | iTo.m20= iValue; 195 | } 196 | static void e21(Matrix4x4 & iTo, double iValue) 197 | { 198 | iTo.m21 = iValue; 199 | } 200 | static void e22(Matrix4x4 & iTo, double iValue) 201 | { 202 | iTo.m22 = iValue; 203 | } 204 | 205 | static void e23(Matrix4x4 & iTo, double iValue) 206 | { 207 | iTo.m23 = iValue; 208 | } 209 | 210 | static void e30(Matrix4x4 & iTo, double iValue) 211 | { 212 | iTo.m30 = iValue; 213 | } 214 | static void e31(Matrix4x4 & iTo, double iValue) 215 | { 216 | iTo.m31 = iValue; 217 | } 218 | static void e32(Matrix4x4 & iTo, double iValue) 219 | { 220 | iTo.m32 = iValue; 221 | } 222 | static void e33(Matrix4x4 & iTo, double iValue) 223 | { 224 | iTo.m33 = iValue; 225 | } 226 | }; 227 | 228 | } // namespace xbb 229 | 230 | 231 | #endif // XBB_MATRIX_4_X_4_H 232 | -------------------------------------------------------------------------------- /include/xbb/MatrixValuesFrom.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_MATRIX_VALUES_FROM_H 29 | #define XBB_MATRIX_VALUES_FROM_H 30 | 31 | namespace xbb { 32 | 33 | template 34 | struct MatrixValuesFrom 35 | { 36 | static double e00(const UserTypeT & /*iFrom*/) 37 | { 38 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 39 | return 1.0; 40 | } 41 | static double e01(const UserTypeT & /*iFrom*/) 42 | { 43 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 44 | return 1.0; 45 | } 46 | static double e02(const UserTypeT & /*iFrom*/) 47 | { 48 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 49 | return 1.0; 50 | } 51 | static double e03(const UserTypeT & /*iFrom*/) 52 | { 53 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 54 | return 1.0; 55 | } 56 | 57 | static double e10(const UserTypeT & /*iFrom*/) 58 | { 59 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 60 | return 1.0; 61 | } 62 | static double e11(const UserTypeT & /*iFrom*/) 63 | { 64 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 65 | return 1.0; 66 | } 67 | static double e12(const UserTypeT & /*iFrom*/) 68 | { 69 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 70 | return 1.0; 71 | } 72 | static double e13(const UserTypeT & /*iFrom*/) 73 | { 74 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 75 | return 1.0; 76 | } 77 | 78 | static double e20(const UserTypeT & /*iFrom*/) 79 | { 80 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 81 | return 1.0; 82 | } 83 | static double e21(const UserTypeT & /*iFrom*/) 84 | { 85 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 86 | return 1.0; 87 | } 88 | static double e22(const UserTypeT & /*iFrom*/) 89 | { 90 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 91 | return 1.0; 92 | } 93 | static double e23(const UserTypeT & /*iFrom*/) 94 | { 95 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 96 | return 1.0; 97 | } 98 | 99 | 100 | static double e30(const UserTypeT & /*iFrom*/) 101 | { 102 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 103 | return 1.0; 104 | } 105 | static double e31(const UserTypeT & /*iFrom*/) 106 | { 107 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 108 | return 1.0; 109 | } 110 | static double e32(const UserTypeT & /*iFrom*/) 111 | { 112 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 113 | return 1.0; 114 | } 115 | static double e33(const UserTypeT & /*iFrom*/) 116 | { 117 | assert(0 && "Caller must provide a specialization of MatrixValuesFrom for their type and implement the e?? methods"); 118 | return 1.0; 119 | } 120 | }; 121 | 122 | 123 | } // namespace xbb 124 | 125 | 126 | #endif // XBB_MATRIX_VALUES_FROM_H 127 | -------------------------------------------------------------------------------- /include/xbb/ProxyMatrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_PROXY_MATRIX_H 29 | #define XBB_PROXY_MATRIX_H 30 | 31 | #include "Base.h" 32 | #include "MatrixValuesFrom.h" 33 | 34 | namespace xbb { 35 | 36 | template< 37 | Constancy c00T, Constancy c01T, Constancy c02T, Constancy c03T, 38 | Constancy c10T, Constancy c11T, Constancy c12T, Constancy c13T, 39 | Constancy c20T, Constancy c21T, Constancy c22T, Constancy c23T, 40 | Constancy c30T, Constancy c31T, Constancy c32T, Constancy c33T, 41 | typename UserTypeT 42 | > 43 | struct ProxyMatrix: 44 | public Base 50 | > 51 | { 52 | ProxyMatrix(const UserTypeT &iTransform) 53 | : mTransform(iTransform) 54 | { 55 | } 56 | 57 | const UserTypeT & mTransform; 58 | 59 | static const InverseProvision inverseProvision = InverseDeprived; 60 | 61 | double e00() const { return MatrixValuesFrom::e00(mTransform); } 62 | double e01() const { return MatrixValuesFrom::e01(mTransform); } 63 | double e02() const { return MatrixValuesFrom::e02(mTransform); } 64 | double e03() const { return MatrixValuesFrom::e03(mTransform); } 65 | 66 | double e10() const { return MatrixValuesFrom::e10(mTransform); } 67 | double e11() const { return MatrixValuesFrom::e11(mTransform); } 68 | double e12() const { return MatrixValuesFrom::e12(mTransform); } 69 | double e13() const { return MatrixValuesFrom::e13(mTransform); } 70 | 71 | double e20() const { return MatrixValuesFrom::e20(mTransform); } 72 | double e21() const { return MatrixValuesFrom::e21(mTransform); } 73 | double e22() const { return MatrixValuesFrom::e22(mTransform); } 74 | double e23() const { return MatrixValuesFrom::e23(mTransform); } 75 | 76 | double e30() const { return MatrixValuesFrom::e30(mTransform); } 77 | double e31() const { return MatrixValuesFrom::e31(mTransform); } 78 | double e32() const { return MatrixValuesFrom::e32(mTransform); } 79 | double e33() const { return MatrixValuesFrom::e33(mTransform); } 80 | 81 | static const Constancy c00 = c00T; 82 | static const Constancy c01 = c01T; 83 | static const Constancy c02 = c02T; 84 | static const Constancy c03 = c03T; 85 | 86 | static const Constancy c10 = c10T; 87 | static const Constancy c11 = c11T; 88 | static const Constancy c12 = c12T; 89 | static const Constancy c13 = c13T; 90 | 91 | static const Constancy c20 = c20T; 92 | static const Constancy c21 = c21T; 93 | static const Constancy c22 = c22T; 94 | static const Constancy c23 = c23T; 95 | 96 | static const Constancy c30 = c30T; 97 | static const Constancy c31 = c31T; 98 | static const Constancy c32 = c32T; 99 | static const Constancy c33 = c33T; 100 | }; 101 | 102 | template 103 | struct ProxyMatrix4x4 : 104 | public ProxyMatrix< 105 | NotConstant, NotConstant, NotConstant, NotConstant, 106 | NotConstant, NotConstant, NotConstant, NotConstant, 107 | NotConstant, NotConstant, NotConstant, NotConstant, 108 | NotConstant, NotConstant, NotConstant, NotConstant, 109 | UserTypeT> 110 | { 111 | ProxyMatrix4x4(const UserTypeT &iTransform) 112 | :ProxyMatrix< 113 | NotConstant, NotConstant, NotConstant, NotConstant, 114 | NotConstant, NotConstant, NotConstant, NotConstant, 115 | NotConstant, NotConstant, NotConstant, NotConstant, 116 | NotConstant, NotConstant, NotConstant, NotConstant, 117 | UserTypeT>(iTransform) 118 | {} 119 | }; 120 | 121 | template 122 | struct ProxyMatrix4x3 : 123 | public ProxyMatrix< 124 | NotConstant, NotConstant, NotConstant, ConstantZero, 125 | NotConstant, NotConstant, NotConstant, ConstantZero, 126 | NotConstant, NotConstant, NotConstant, ConstantZero, 127 | NotConstant, NotConstant, NotConstant, ConstantOne, 128 | UserTypeT> 129 | { 130 | typedef ProxyMatrix< 131 | NotConstant, NotConstant, NotConstant, ConstantZero, 132 | NotConstant, NotConstant, NotConstant, ConstantZero, 133 | NotConstant, NotConstant, NotConstant, ConstantZero, 134 | NotConstant, NotConstant, NotConstant, ConstantOne, 135 | UserTypeT> Base; 136 | 137 | ProxyMatrix4x3(const UserTypeT &iTransform) 138 | : Base(iTransform) 139 | {} 140 | }; 141 | 142 | template 143 | struct ProxyMatrix3x3 : 144 | public ProxyMatrix< 145 | NotConstant, NotConstant, NotConstant, ConstantZero, 146 | NotConstant, NotConstant, NotConstant, ConstantZero, 147 | NotConstant, NotConstant, NotConstant, ConstantZero, 148 | ConstantZero, ConstantZero, ConstantZero, ConstantOne, 149 | UserTypeT> 150 | { 151 | typedef ProxyMatrix< 152 | NotConstant, NotConstant, NotConstant, ConstantZero, 153 | NotConstant, NotConstant, NotConstant, ConstantZero, 154 | NotConstant, NotConstant, NotConstant, ConstantZero, 155 | ConstantZero, ConstantZero, ConstantZero, ConstantOne, 156 | UserTypeT> Base; 157 | 158 | ProxyMatrix3x3(const UserTypeT &iTransform) 159 | : Base(iTransform) 160 | {} 161 | }; 162 | 163 | 164 | // Enable ProxyMatrix to be used with a ProxyMatrix 165 | // common use case is to mask out/off components 166 | template< 167 | Constancy c00T, Constancy c01T, Constancy c02T, Constancy c03T, 168 | Constancy c10T, Constancy c11T, Constancy c12T, Constancy c13T, 169 | Constancy c20T, Constancy c21T, Constancy c22T, Constancy c23T, 170 | Constancy c30T, Constancy c31T, Constancy c32T, Constancy c33T, 171 | typename UserTypeT 172 | > 173 | struct MatrixValuesFrom< 174 | ProxyMatrix< 175 | c00T, c01T, c02T, c03T, 176 | c10T, c11T, c12T, c13T, 177 | c20T, c21T, c22T, c23T, 178 | c30T, c31T, c32T, c33T, 179 | UserTypeT 180 | > 181 | > 182 | { 183 | typedef ProxyMatrix< 184 | c00T, c01T, c02T, c03T, 185 | c10T, c11T, c12T, c13T, 186 | c20T, c21T, c22T, c23T, 187 | c30T, c31T, c32T, c33T, 188 | UserTypeT> ProxyType; 189 | 190 | static double e00(const ProxyType & iFrom) 191 | { 192 | return iFrom.e00(); 193 | } 194 | static double e01(const ProxyType & iFrom) 195 | { 196 | return iFrom.e01(); 197 | } 198 | static double e02(const ProxyType & iFrom) 199 | { 200 | return iFrom.e02(); 201 | } 202 | 203 | static double e03(const ProxyType & iFrom) 204 | { 205 | return iFrom.e03(); 206 | } 207 | 208 | static double e10(const ProxyType & iFrom) 209 | { 210 | return iFrom.e10(); 211 | } 212 | static double e11(const ProxyType & iFrom) 213 | { 214 | return iFrom.e11(); 215 | } 216 | static double e12(const ProxyType & iFrom) 217 | { 218 | return iFrom.e12(); 219 | } 220 | 221 | static double e13(const ProxyType & iFrom) 222 | { 223 | return iFrom.e13(); 224 | } 225 | 226 | static double e20(const ProxyType & iFrom) 227 | { 228 | return iFrom.e20(); 229 | } 230 | static double e21(const ProxyType & iFrom) 231 | { 232 | return iFrom.e21(); 233 | } 234 | static double e22(const ProxyType & iFrom) 235 | { 236 | return iFrom.e22(); 237 | } 238 | 239 | static double e23(const ProxyType & iFrom) 240 | { 241 | return iFrom.e23(); 242 | } 243 | 244 | static double e30(const ProxyType & iFrom) 245 | { 246 | return iFrom.e30(); 247 | } 248 | static double e31(const ProxyType & iFrom) 249 | { 250 | return iFrom.e31(); 251 | } 252 | static double e32(const ProxyType & iFrom) 253 | { 254 | return iFrom.e32(); 255 | } 256 | static double e33(const ProxyType & iFrom) 257 | { 258 | return iFrom.e33(); 259 | } 260 | }; 261 | 262 | template 263 | struct MatrixValuesFrom< 264 | ProxyMatrix4x3 265 | > : public MatrixValuesFrom::Base> 266 | { 267 | }; 268 | 269 | template 270 | struct MatrixValuesFrom< 271 | ProxyMatrix3x3 272 | > : public MatrixValuesFrom::Base> 273 | { 274 | }; 275 | 276 | } // namespace xbb 277 | 278 | 279 | #endif // XBB_PROXY_MATRIX_H 280 | -------------------------------------------------------------------------------- /include/xbb/RotationX.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_ROTATION_X_H 29 | #define XBB_ROTATION_X_H 30 | 31 | #include 32 | #include "Base.h" 33 | 34 | namespace xbb { 35 | 36 | struct InverseRotationX; 37 | 38 | struct RotationX : 39 | public Base 40 | { 41 | RotationX() 42 | { 43 | // uninitialized 44 | } 45 | 46 | RotationX(double aCosineOfAngle, double aSineOfAngle) 47 | : cosineOfAngle(aCosineOfAngle) 48 | , sineOfAngle(aSineOfAngle) 49 | {} 50 | 51 | void setToZero() 52 | { 53 | cosineOfAngle = 1.0; 54 | sineOfAngle = 0.0; 55 | } 56 | 57 | void set(double aAngle) 58 | { 59 | cosineOfAngle = cos(aAngle); 60 | sineOfAngle = sin(aAngle); 61 | } 62 | 63 | void set(double aCosineOfAngle, double aSineOfAngle) 64 | { 65 | cosineOfAngle = aCosineOfAngle; 66 | sineOfAngle = aSineOfAngle; 67 | } 68 | 69 | RotationX(double aAngle) 70 | { 71 | set(aAngle); 72 | } 73 | 74 | double cosineOfAngle; 75 | double sineOfAngle; 76 | 77 | static const InverseProvision inverseProvision = InverseProvided; 78 | 79 | typedef InverseRotationX InverseType; 80 | inline InverseType inverse() const; 81 | 82 | double e00() const { return 1.0; } 83 | double e01() const { return 0.0; } 84 | double e02() const { return 0.0; } 85 | double e03() const { return 0.0; } 86 | 87 | double e10() const { return 0.0; } 88 | double e11() const { return cosineOfAngle; } 89 | double e12() const { return sineOfAngle; } 90 | double e13() const { return 0.0; } 91 | 92 | double e20() const { return 0.0; } 93 | double e21() const { return -sineOfAngle; } 94 | double e22() const { return cosineOfAngle; } 95 | double e23() const { return 0.0; } 96 | 97 | double e30() const { return 0.0; } 98 | double e31() const { return 0.0; } 99 | double e32() const { return 0.0; } 100 | double e33() const { return 1.0; } 101 | 102 | 103 | static const Constancy c00 = ConstantOne; 104 | static const Constancy c01 = ConstantZero; 105 | static const Constancy c02 = ConstantZero; 106 | static const Constancy c03 = ConstantZero; 107 | 108 | static const Constancy c10 = ConstantZero; 109 | static const Constancy c11 = NotConstant; 110 | static const Constancy c12 = NotConstant; 111 | static const Constancy c13 = ConstantZero; 112 | 113 | static const Constancy c20 = ConstantZero; 114 | static const Constancy c21 = NotConstant; 115 | static const Constancy c22 = NotConstant; 116 | static const Constancy c23 = ConstantZero; 117 | 118 | static const Constancy c30 = ConstantZero; 119 | static const Constancy c31 = ConstantZero; 120 | static const Constancy c32 = ConstantZero; 121 | static const Constancy c33 = ConstantOne; 122 | 123 | }; 124 | 125 | 126 | struct InverseRotationX : 127 | public Base 128 | { 129 | InverseRotationX() 130 | { 131 | // unitialized 132 | } 133 | 134 | InverseRotationX(double aCosineOfAngle, double aSineOfAngle) 135 | : cosineOfAngle(aCosineOfAngle) 136 | , sineOfAngle(aSineOfAngle) 137 | {} 138 | 139 | void setToZero() 140 | { 141 | cosineOfAngle = 1.0; 142 | sineOfAngle = 0.0; 143 | } 144 | 145 | void set(double aAngle) 146 | { 147 | cosineOfAngle = cos(aAngle); 148 | sineOfAngle = sin(aAngle); 149 | } 150 | 151 | InverseRotationX(double aAngle) 152 | { 153 | set(aAngle); 154 | } 155 | 156 | double cosineOfAngle; 157 | double sineOfAngle; 158 | 159 | static const InverseProvision inverseProvision = InverseProvided; 160 | typedef RotationX InverseType; 161 | InverseType inverse() const { return InverseType(cosineOfAngle, sineOfAngle); } 162 | 163 | double e00() const { return 1.0; } 164 | double e01() const { return 0.0; } 165 | double e02() const { return 0.0; } 166 | double e03() const { return 0.0; } 167 | 168 | double e10() const { return 0.0; } 169 | double e11() const { return cosineOfAngle; } 170 | double e12() const { return -sineOfAngle; } 171 | double e13() const { return 0.0; } 172 | 173 | double e20() const { return 0.0; } 174 | double e21() const { return sineOfAngle; } 175 | double e22() const { return cosineOfAngle; } 176 | double e23() const { return 0.0; } 177 | 178 | double e30() const { return 0.0; } 179 | double e31() const { return 0.0; } 180 | double e32() const { return 0.0; } 181 | double e33() const { return 1.0; } 182 | 183 | 184 | static const Constancy c00 = ConstantOne; 185 | static const Constancy c01 = ConstantZero; 186 | static const Constancy c02 = ConstantZero; 187 | static const Constancy c03 = ConstantZero; 188 | 189 | static const Constancy c10 = ConstantZero; 190 | static const Constancy c11 = NotConstant; 191 | static const Constancy c12 = NotConstant; 192 | static const Constancy c13 = ConstantZero; 193 | 194 | static const Constancy c20 = ConstantZero; 195 | static const Constancy c21 = NotConstant; 196 | static const Constancy c22 = NotConstant; 197 | static const Constancy c23 = ConstantZero; 198 | 199 | static const Constancy c30 = ConstantZero; 200 | static const Constancy c31 = ConstantZero; 201 | static const Constancy c32 = ConstantZero; 202 | static const Constancy c33 = ConstantOne; 203 | 204 | }; 205 | 206 | RotationX::InverseType 207 | RotationX::inverse() const 208 | { 209 | return InverseType(cosineOfAngle, sineOfAngle); 210 | } 211 | 212 | } // namespace xbb 213 | 214 | #endif // XBB_ROTATION_X_H 215 | -------------------------------------------------------------------------------- /include/xbb/RotationY.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_ROTATION_Y_H 29 | #define XBB_ROTATION_Y_H 30 | 31 | #include "Base.h" 32 | 33 | namespace xbb { 34 | 35 | struct InverseRotationY; 36 | 37 | struct RotationY : 38 | public Base 39 | { 40 | RotationY() 41 | { 42 | // uninitialized 43 | } 44 | 45 | RotationY(double aCosineOfAngle, double aSineOfAngle) 46 | : cosineOfAngle(aCosineOfAngle) 47 | , sineOfAngle(aSineOfAngle) 48 | {} 49 | 50 | void setToZero() 51 | { 52 | cosineOfAngle = 1.0; 53 | sineOfAngle = 0.0; 54 | } 55 | 56 | void set(double aAngle) 57 | { 58 | cosineOfAngle = cos(aAngle); 59 | sineOfAngle = sin(aAngle); 60 | } 61 | 62 | void set(double aCosineOfAngle, double aSineOfAngle) 63 | { 64 | cosineOfAngle = aCosineOfAngle; 65 | sineOfAngle = aSineOfAngle; 66 | } 67 | 68 | 69 | RotationY(double aAngle) 70 | { 71 | set(aAngle); 72 | } 73 | 74 | 75 | double cosineOfAngle; 76 | double sineOfAngle; 77 | 78 | static const InverseProvision inverseProvision = InverseProvided; 79 | 80 | typedef InverseRotationY InverseType; 81 | inline InverseType inverse() const; 82 | 83 | double e00() const { return cosineOfAngle; } 84 | double e01() const { return 0.0; } 85 | double e02() const { return -sineOfAngle; } 86 | double e03() const { return 0.0; } 87 | 88 | double e10() const { return 0.0; } 89 | double e11() const { return 1.0; } 90 | double e12() const { return 0.0; } 91 | double e13() const { return 0.0; } 92 | 93 | double e20() const { return sineOfAngle; } 94 | double e21() const { return 0.0; } 95 | double e22() const { return cosineOfAngle; } 96 | double e23() const { return 0.0; } 97 | 98 | double e30() const { return 0.0; } 99 | double e31() const { return 0.0; } 100 | double e32() const { return 0.0; } 101 | double e33() const { return 1.0; } 102 | 103 | static const Constancy c00 = NotConstant; 104 | static const Constancy c01 = ConstantZero; 105 | static const Constancy c02 = NotConstant; 106 | static const Constancy c03 = ConstantZero; 107 | 108 | static const Constancy c10 = ConstantZero; 109 | static const Constancy c11 = ConstantOne; 110 | static const Constancy c12 = ConstantZero; 111 | static const Constancy c13 = ConstantZero; 112 | 113 | static const Constancy c20 = NotConstant; 114 | static const Constancy c21 = ConstantZero; 115 | static const Constancy c22 = NotConstant; 116 | static const Constancy c23 = ConstantZero; 117 | 118 | static const Constancy c30 = ConstantZero; 119 | static const Constancy c31 = ConstantZero; 120 | static const Constancy c32 = ConstantZero; 121 | static const Constancy c33 = ConstantOne; 122 | }; 123 | 124 | 125 | struct InverseRotationY : 126 | public Base 127 | { 128 | InverseRotationY() 129 | { 130 | // unitialized 131 | } 132 | 133 | InverseRotationY(double aCosineOfAngle, double aSineOfAngle) 134 | : cosineOfAngle(aCosineOfAngle) 135 | , sineOfAngle(aSineOfAngle) 136 | {} 137 | 138 | void setToZero() 139 | { 140 | cosineOfAngle = 1.0; 141 | sineOfAngle = 0.0; 142 | } 143 | 144 | void set(double aAngle) 145 | { 146 | cosineOfAngle = cos(aAngle); 147 | sineOfAngle = sin(aAngle); 148 | } 149 | 150 | InverseRotationY(double aAngle) 151 | { 152 | set(aAngle); 153 | } 154 | 155 | 156 | double cosineOfAngle; 157 | double sineOfAngle; 158 | 159 | static const InverseProvision inverseProvision = InverseProvided; 160 | typedef RotationY InverseType; 161 | InverseType inverse() const { return InverseType(cosineOfAngle, sineOfAngle); } 162 | 163 | double e00() const { return cosineOfAngle; } 164 | double e01() const { return 0.0; } 165 | double e02() const { return sineOfAngle; } 166 | double e03() const { return 0.0; } 167 | 168 | double e10() const { return 0.0; } 169 | double e11() const { return 1.0; } 170 | double e12() const { return 0.0; } 171 | double e13() const { return 0.0; } 172 | 173 | double e20() const { return -sineOfAngle; } 174 | double e21() const { return 0.0; } 175 | double e22() const { return cosineOfAngle; } 176 | double e23() const { return 0.0; } 177 | 178 | double e30() const { return 0.0; } 179 | double e31() const { return 0.0; } 180 | double e32() const { return 0.0; } 181 | double e33() const { return 1.0; } 182 | 183 | static const Constancy c00 = NotConstant; 184 | static const Constancy c01 = ConstantZero; 185 | static const Constancy c02 = NotConstant; 186 | static const Constancy c03 = ConstantZero; 187 | 188 | static const Constancy c10 = ConstantZero; 189 | static const Constancy c11 = ConstantOne; 190 | static const Constancy c12 = ConstantZero; 191 | static const Constancy c13 = ConstantZero; 192 | 193 | static const Constancy c20 = NotConstant; 194 | static const Constancy c21 = ConstantZero; 195 | static const Constancy c22 = NotConstant; 196 | static const Constancy c23 = ConstantZero; 197 | 198 | static const Constancy c30 = ConstantZero; 199 | static const Constancy c31 = ConstantZero; 200 | static const Constancy c32 = ConstantZero; 201 | static const Constancy c33 = ConstantOne; 202 | 203 | }; 204 | 205 | 206 | RotationY::InverseType 207 | RotationY::inverse() const 208 | { 209 | return InverseType(cosineOfAngle, sineOfAngle); 210 | } 211 | 212 | } // namespace xbb 213 | 214 | #endif // XBB_ROTATION_Y_H 215 | -------------------------------------------------------------------------------- /include/xbb/RotationZ.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_ROTATION_Z_H 29 | #define XBB_ROTATION_Z_H 30 | 31 | #include "Base.h" 32 | 33 | namespace xbb { 34 | 35 | struct InverseRotationZ; 36 | 37 | struct RotationZ : 38 | public Base 39 | { 40 | RotationZ() 41 | { 42 | // uninitialized 43 | } 44 | 45 | RotationZ(double aCosineOfAngle, double aSineOfAngle) 46 | : cosineOfAngle(aCosineOfAngle) 47 | , sineOfAngle(aSineOfAngle) 48 | {} 49 | 50 | void setToZero() 51 | { 52 | cosineOfAngle = 1.0; 53 | sineOfAngle = 0.0; 54 | } 55 | 56 | void set(double aAngle) 57 | { 58 | cosineOfAngle = cos(aAngle); 59 | sineOfAngle = sin(aAngle); 60 | } 61 | 62 | void set(double aCosineOfAngle, double aSineOfAngle) 63 | { 64 | cosineOfAngle = aCosineOfAngle; 65 | sineOfAngle = aSineOfAngle; 66 | } 67 | 68 | RotationZ(double aAngle) 69 | { 70 | set(aAngle); 71 | } 72 | 73 | double cosineOfAngle; 74 | double sineOfAngle; 75 | 76 | static const InverseProvision inverseProvision = InverseProvided; 77 | typedef InverseRotationZ InverseType; 78 | inline InverseType inverse() const; 79 | 80 | double e00() const { return cosineOfAngle; } 81 | double e01() const { return sineOfAngle; } 82 | double e02() const { return 0.0; } 83 | double e03() const { return 0.0; } 84 | 85 | double e10() const { return -sineOfAngle; } 86 | double e11() const { return cosineOfAngle; } 87 | double e12() const { return 0.0; } 88 | double e13() const { return 0.0; } 89 | 90 | double e20() const { return 0.0; } 91 | double e21() const { return 0.0; } 92 | double e22() const { return 1.0; } 93 | double e23() const { return 0.0; } 94 | 95 | double e30() const { return 0.0; } 96 | double e31() const { return 0.0; } 97 | double e32() const { return 0.0; } 98 | double e33() const { return 1.0; } 99 | 100 | static const Constancy c00 = NotConstant; 101 | static const Constancy c01 = NotConstant; 102 | static const Constancy c02 = ConstantZero; 103 | static const Constancy c03 = ConstantZero; 104 | 105 | static const Constancy c10 = NotConstant; 106 | static const Constancy c11 = NotConstant; 107 | static const Constancy c12 = ConstantZero; 108 | static const Constancy c13 = ConstantZero; 109 | 110 | static const Constancy c20 = ConstantZero; 111 | static const Constancy c21 = ConstantZero; 112 | static const Constancy c22 = ConstantOne; 113 | static const Constancy c23 = ConstantZero; 114 | 115 | static const Constancy c30 = ConstantZero; 116 | static const Constancy c31 = ConstantZero; 117 | static const Constancy c32 = ConstantZero; 118 | static const Constancy c33 = ConstantOne; 119 | }; 120 | 121 | 122 | struct InverseRotationZ : 123 | public Base 124 | { 125 | InverseRotationZ() 126 | { 127 | // unitialized 128 | } 129 | 130 | InverseRotationZ(double aCosineOfAngle, double aSineOfAngle) 131 | : cosineOfAngle(aCosineOfAngle) 132 | , sineOfAngle(aSineOfAngle) 133 | {} 134 | 135 | void setToZero() 136 | { 137 | cosineOfAngle = 1.0; 138 | sineOfAngle = 0.0; 139 | } 140 | 141 | void set(double aAngle) 142 | { 143 | cosineOfAngle = cos(aAngle); 144 | sineOfAngle = sin(aAngle); 145 | } 146 | 147 | 148 | InverseRotationZ(double aAngle) 149 | { 150 | set(aAngle); 151 | } 152 | 153 | double cosineOfAngle; 154 | double sineOfAngle; 155 | 156 | static const InverseProvision inverseProvision = InverseProvided; 157 | typedef RotationZ InverseType; 158 | InverseType inverse() const { return InverseType(cosineOfAngle, sineOfAngle); } 159 | 160 | double e00() const { return cosineOfAngle; } 161 | double e01() const { return -sineOfAngle; } 162 | double e02() const { return 0.0; } 163 | double e03() const { return 0.0; } 164 | 165 | double e10() const { return sineOfAngle; } 166 | double e11() const { return cosineOfAngle; } 167 | double e12() const { return 0.0; } 168 | double e13() const { return 0.0; } 169 | 170 | double e20() const { return 0.0; } 171 | double e21() const { return 0.0; } 172 | double e22() const { return 1.0; } 173 | double e23() const { return 0.0; } 174 | 175 | double e30() const { return 0.0; } 176 | double e31() const { return 0.0; } 177 | double e32() const { return 0.0; } 178 | double e33() const { return 1.0; } 179 | 180 | static const Constancy c00 = NotConstant; 181 | static const Constancy c01 = NotConstant; 182 | static const Constancy c02 = ConstantZero; 183 | static const Constancy c03 = ConstantZero; 184 | 185 | static const Constancy c10 = NotConstant; 186 | static const Constancy c11 = NotConstant; 187 | static const Constancy c12 = ConstantZero; 188 | static const Constancy c13 = ConstantZero; 189 | 190 | static const Constancy c20 = ConstantZero; 191 | static const Constancy c21 = ConstantZero; 192 | static const Constancy c22 = ConstantOne; 193 | static const Constancy c23 = ConstantZero; 194 | 195 | static const Constancy c30 = ConstantZero; 196 | static const Constancy c31 = ConstantZero; 197 | static const Constancy c32 = ConstantZero; 198 | static const Constancy c33 = ConstantOne; 199 | 200 | }; 201 | 202 | 203 | 204 | RotationZ::InverseType 205 | RotationZ::inverse() const 206 | { 207 | return InverseType(cosineOfAngle, sineOfAngle); 208 | } 209 | 210 | } // namespace xbb 211 | 212 | #endif // XBB_ROTATION_Z_H 213 | -------------------------------------------------------------------------------- /include/xbb/Scale.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_SCALE_H 29 | #define XBB_SCALE_H 30 | 31 | #include "Base.h" 32 | 33 | namespace xbb { 34 | 35 | template 36 | struct ScaleValuesFrom 37 | { 38 | static double x(const UserTypeT & /*iFrom*/) 39 | { 40 | assert(0 && "Caller must provide a specialization of ScaleValuesFrom for their type and implement the x(), y(), z() methods"); 41 | return 1.0; 42 | } 43 | static double y(const UserTypeT & /*iFrom*/) 44 | { 45 | assert(0 && "Caller must provide a specialization of ScaleValuesFrom for their type and implement the x(), y(), z() methods"); 46 | return 1.0; 47 | } 48 | static double z(const UserTypeT & /*iFrom*/) 49 | { 50 | assert(0 && "Caller must provide a specialization of ScaleValuesFrom for their type and implement the x(), y(), z() methods"); 51 | return 1.0; 52 | } 53 | }; 54 | 55 | struct InverseScale; 56 | 57 | struct Scale : 58 | public Base 59 | { 60 | Scale() 61 | { 62 | // uninitialized 63 | } 64 | 65 | Scale(double iX, double iY, double iZ) 66 | : x(iX) 67 | , y(iY) 68 | , z(iZ) 69 | {} 70 | 71 | template 72 | Scale(const UserTypeT &iValue) 73 | : x(ScaleValuesFrom::x(iValue)) 74 | , y(ScaleValuesFrom::y(iValue)) 75 | , z(ScaleValuesFrom::z(iValue)) 76 | {} 77 | 78 | void set(double iX, double iY, double iZ) 79 | { 80 | x = iX; 81 | y = iY; 82 | z = iZ; 83 | } 84 | 85 | double x; 86 | double y; 87 | double z; 88 | 89 | static const InverseProvision inverseProvision = InverseProvided; 90 | typedef InverseScale InverseType; 91 | inline InverseType inverse() const; 92 | 93 | double e00() const { return x; } 94 | double e01() const { return 0.0; } 95 | double e02() const { return 0.0; } 96 | double e03() const { return 0.0; } 97 | 98 | double e10() const { return 0.0; } 99 | double e11() const { return y; } 100 | double e12() const { return 0.0; } 101 | double e13() const { return 0.0; } 102 | 103 | double e20() const { return 0.0; } 104 | double e21() const { return 0.0; } 105 | double e22() const { return z; } 106 | double e23() const { return 0.0; } 107 | 108 | double e30() const { return 0.0; } 109 | double e31() const { return 0.0; } 110 | double e32() const { return 0.0; } 111 | double e33() const { return 1.0; } 112 | 113 | static const Constancy c00 = NotConstant; 114 | static const Constancy c01 = ConstantZero; 115 | static const Constancy c02 = ConstantZero; 116 | static const Constancy c03 = ConstantZero; 117 | 118 | static const Constancy c10 = ConstantZero; 119 | static const Constancy c11 = NotConstant; 120 | static const Constancy c12 = ConstantZero; 121 | static const Constancy c13 = ConstantZero; 122 | 123 | static const Constancy c20 = ConstantZero; 124 | static const Constancy c21 = ConstantZero; 125 | static const Constancy c22 = NotConstant; 126 | static const Constancy c23 = ConstantZero; 127 | 128 | static const Constancy c30 = ConstantZero; 129 | static const Constancy c31 = ConstantZero; 130 | static const Constancy c32 = ConstantZero; 131 | static const Constancy c33 = ConstantOne; 132 | 133 | }; 134 | 135 | struct InverseScale : 136 | public Base 137 | { 138 | InverseScale() 139 | { 140 | // unitialized 141 | } 142 | 143 | InverseScale(double iX, double iY, double iZ) 144 | : x(iX) 145 | , y(iY) 146 | , z(iZ) 147 | {} 148 | 149 | template 150 | InverseScale(const UserTypeT &iValue) 151 | : x(ScaleValuesFrom::x(iValue)) 152 | , y(ScaleValuesFrom::y(iValue)) 153 | , z(ScaleValuesFrom::z(iValue)) 154 | {} 155 | 156 | double x; 157 | double y; 158 | double z; 159 | 160 | static const InverseProvision inverseProvision = InverseProvided; 161 | typedef Scale InverseType; 162 | InverseType inverse() const { return InverseType(x, y, z); } 163 | 164 | 165 | double e00() const { return 1.0/x; } 166 | double e01() const { return 0.0; } 167 | double e02() const { return 0.0; } 168 | double e03() const { return 0.0; } 169 | 170 | double e10() const { return 0.0; } 171 | double e11() const { return 1.0/y; } 172 | double e12() const { return 0.0; } 173 | double e13() const { return 0.0; } 174 | 175 | double e20() const { return 0.0; } 176 | double e21() const { return 0.0; } 177 | double e22() const { return 1.0/z; } 178 | double e23() const { return 0.0; } 179 | 180 | double e30() const { return 0.0; } 181 | double e31() const { return 0.0; } 182 | double e32() const { return 0.0; } 183 | double e33() const { return 1.0; } 184 | 185 | static const Constancy c00 = NotConstant; 186 | static const Constancy c01 = ConstantZero; 187 | static const Constancy c02 = ConstantZero; 188 | static const Constancy c03 = ConstantZero; 189 | 190 | static const Constancy c10 = ConstantZero; 191 | static const Constancy c11 = NotConstant; 192 | static const Constancy c12 = ConstantZero; 193 | static const Constancy c13 = ConstantZero; 194 | 195 | static const Constancy c20 = ConstantZero; 196 | static const Constancy c21 = ConstantZero; 197 | static const Constancy c22 = NotConstant; 198 | static const Constancy c23 = ConstantZero; 199 | 200 | static const Constancy c30 = ConstantZero; 201 | static const Constancy c31 = ConstantZero; 202 | static const Constancy c32 = ConstantZero; 203 | static const Constancy c33 = ConstantOne; 204 | }; 205 | 206 | 207 | Scale::InverseType 208 | Scale::inverse() const 209 | { 210 | return InverseType(x, y, z); 211 | } 212 | 213 | } // namespace xbb 214 | 215 | #endif // XBB_SCALE_H 216 | -------------------------------------------------------------------------------- /include/xbb/Shear3.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_SHEAR_3_H 29 | #define XBB_SHEAR_3_H 30 | 31 | #include "Axis.h" 32 | #include "Base.h" 33 | 34 | namespace xbb { 35 | 36 | // Adapter that user would provide a specialized version for their type 37 | // to be able to pass their type as a constructor parameter to a Shear3 38 | template 39 | struct Shear3ValuesFrom 40 | { 41 | static double x(const UserTypeT & /*iFrom*/) 42 | { 43 | assert(0 && "Caller must provide a specialization of Shear3ValuesFrom for their type and implement the x(), y(), z() methods"); 44 | return 1.0; 45 | } 46 | static double y(const UserTypeT & /*iFrom*/) 47 | { 48 | assert(0 && "Caller must provide a specialization of Shear3ValuesFrom for their type and implement the x(), y(), z() methods"); 49 | return 1.0; 50 | } 51 | static double z(const UserTypeT & /*iFrom*/) 52 | { 53 | assert(0 && "Caller must provide a specialization of Shear3ValuesFrom for their type and implement the x(), y(), z() methods"); 54 | return 1.0; 55 | } 56 | }; 57 | 58 | // Forward declaration 59 | struct InverseShear3; 60 | 61 | 62 | struct Shear3 : 63 | public Base 64 | { 65 | Shear3() 66 | { 67 | // uninitialized 68 | } 69 | 70 | Shear3(double iX, double iY, double iZ) 71 | : x(iX) 72 | , y(iY) 73 | , z(iZ) 74 | {} 75 | 76 | template 77 | Shear3(const UserTypeT &iValue) 78 | : x(Shear3ValuesFrom::x(iValue)) 79 | , y(Shear3ValuesFrom::y(iValue)) 80 | , z(Shear3ValuesFrom::z(iValue)) 81 | {} 82 | 83 | void set(double iX, double iY, double iZ) 84 | { 85 | x = iX; 86 | y = iY; 87 | z = iZ; 88 | } 89 | 90 | double x; 91 | double y; 92 | double z; 93 | 94 | static const InverseProvision inverseProvision = InverseProvided; 95 | typedef InverseShear3 InverseType; 96 | inline InverseType inverse() const; 97 | 98 | double e00() const { return 1.0; } 99 | double e01() const { return 0.0; } 100 | double e02() const { return 0.0; } 101 | double e03() const { return 0.0; } 102 | 103 | double e10() const { return x; } 104 | double e11() const { return 1.0; } 105 | double e12() const { return 0.0; } 106 | double e13() const { return 0.0; } 107 | 108 | double e20() const { return y; } 109 | double e21() const { return z; } 110 | double e22() const { return 1.0; } 111 | double e23() const { return 0.0; } 112 | 113 | double e30() const { return 0.0; } 114 | double e31() const { return 0.0; } 115 | double e32() const { return 0.0; } 116 | double e33() const { return 1.0; } 117 | 118 | static const Constancy c00 = ConstantOne; 119 | static const Constancy c01 = ConstantZero; 120 | static const Constancy c02 = ConstantZero; 121 | static const Constancy c03 = ConstantZero; 122 | 123 | static const Constancy c10 = NotConstant; 124 | static const Constancy c11 = ConstantOne; 125 | static const Constancy c12 = ConstantZero; 126 | static const Constancy c13 = ConstantZero; 127 | 128 | static const Constancy c20 = NotConstant; 129 | static const Constancy c21 = NotConstant; 130 | static const Constancy c22 = ConstantOne; 131 | static const Constancy c23 = ConstantZero; 132 | 133 | static const Constancy c30 = ConstantZero; 134 | static const Constancy c31 = ConstantZero; 135 | static const Constancy c32 = ConstantZero; 136 | static const Constancy c33 = ConstantOne; 137 | }; 138 | 139 | 140 | struct InverseShear3 : 141 | public Base 142 | { 143 | InverseShear3() 144 | { 145 | // uninitialized 146 | } 147 | 148 | InverseShear3(double iX, double iY, double iZ) 149 | : x(iX) 150 | , y(iY) 151 | , z(iZ) 152 | {} 153 | 154 | double x; 155 | double y; 156 | double z; 157 | 158 | static const InverseProvision inverseProvision = InverseProvided; 159 | typedef Shear3 InverseType; 160 | InverseType inverse() const { return InverseType(x, y, z); } 161 | 162 | double e00() const { return 1.0; } 163 | double e01() const { return 0.0; } 164 | double e02() const { return 0.0; } 165 | double e03() const { return 0.0; } 166 | 167 | double e10() const { return -x; } 168 | double e11() const { return 1.0; } 169 | double e12() const { return 0.0; } 170 | double e13() const { return 0.0; } 171 | 172 | double e20() const { return -y + (x*z); } 173 | double e21() const { return -z; } 174 | double e22() const { return 1.0; } 175 | double e23() const { return 0.0; } 176 | 177 | double e30() const { return 0.0; } 178 | double e31() const { return 0.0; } 179 | double e32() const { return 0.0; } 180 | double e33() const { return 1.0; } 181 | 182 | static const Constancy c00 = ConstantOne; 183 | static const Constancy c01 = ConstantZero; 184 | static const Constancy c02 = ConstantZero; 185 | static const Constancy c03 = ConstantZero; 186 | 187 | static const Constancy c10 = NotConstant; 188 | static const Constancy c11 = ConstantOne; 189 | static const Constancy c12 = ConstantZero; 190 | static const Constancy c13 = ConstantZero; 191 | 192 | static const Constancy c20 = NotConstant; 193 | static const Constancy c21 = NotConstant; 194 | static const Constancy c22 = ConstantOne; 195 | static const Constancy c23 = ConstantZero; 196 | 197 | static const Constancy c30 = ConstantZero; 198 | static const Constancy c31 = ConstantZero; 199 | static const Constancy c32 = ConstantZero; 200 | static const Constancy c33 = ConstantOne; 201 | }; 202 | 203 | Shear3::InverseType 204 | Shear3::inverse() const 205 | { 206 | return InverseType(x, y, z); 207 | } 208 | 209 | } // namespace xbb 210 | 211 | #endif // XBB_SHEAR_3_H 212 | -------------------------------------------------------------------------------- /include/xbb/Transforms.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_TRANSFORMS_H 29 | #define XBB_TRANSFORMS_H 30 | 31 | // For convenience this file includes all the different transforms 32 | #include "Identity.h" 33 | #include "Matrix3x3.h" 34 | #include "Matrix4x3.h" 35 | #include "Matrix4x4.h" 36 | #include "Multiply.h" 37 | #include "ProxyMatrix.h" 38 | #include "RotationX.h" 39 | #include "RotationY.h" 40 | #include "RotationZ.h" 41 | #include "Scale.h" 42 | #include "ShearOf.h" 43 | #include "Shear3.h" 44 | #include "Transpose.h" 45 | #include "Translation.h" 46 | 47 | #endif // XBB_TRANSFORMS_H 48 | -------------------------------------------------------------------------------- /include/xbb/Translation.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_TRANSLATION_H 29 | #define XBB_TRANSLATION_H 30 | 31 | #include "Base.h" 32 | 33 | namespace xbb { 34 | 35 | template 36 | struct TranslateValuesFrom 37 | { 38 | static double x(const UserTypeT & /*iFrom*/) 39 | { 40 | assert(0 && "Caller must provide a specialization of TranslateValuesFrom for their type and implement the x(), y(), z() methods"); 41 | return 1.0; 42 | } 43 | static double y(const UserTypeT & /*iFrom*/) 44 | { 45 | assert(0 && "Caller must provide a specialization of TranslateValuesFrom for their type and implement the x(), y(), z() methods"); 46 | return 1.0; 47 | } 48 | static double z(const UserTypeT & /*iFrom*/) 49 | { 50 | assert(0 && "Caller must provide a specialization of TranslateValuesFrom for their type and implement the x(), y(), z() methods"); 51 | return 1.0; 52 | } 53 | }; 54 | 55 | struct InverseTranslation; 56 | 57 | struct Translation : 58 | public Base 59 | { 60 | Translation() 61 | { 62 | // uninitialized 63 | } 64 | 65 | Translation(double iX, double iY, double iZ) 66 | : x(iX) 67 | , y(iY) 68 | , z(iZ) 69 | {} 70 | 71 | template 72 | Translation(const UserTypeT &iValue) 73 | : x(TranslateValuesFrom::x(iValue)) 74 | , y(TranslateValuesFrom::y(iValue)) 75 | , z(TranslateValuesFrom::z(iValue)) 76 | {} 77 | 78 | void set(double iX, double iY, double iZ) 79 | { 80 | x = iX; 81 | y = iY; 82 | z = iZ; 83 | } 84 | 85 | double x; 86 | double y; 87 | double z; 88 | 89 | static const InverseProvision inverseProvision = InverseProvided; 90 | typedef InverseTranslation InverseType; 91 | inline InverseType inverse() const; 92 | 93 | double e00() const { return 1.0; } 94 | double e01() const { return 0.0; } 95 | double e02() const { return 0.0; } 96 | double e03() const { return 0.0; } 97 | 98 | double e10() const { return 0.0; } 99 | double e11() const { return 1.0; } 100 | double e12() const { return 0.0; } 101 | double e13() const { return 0.0; } 102 | 103 | double e20() const { return 0.0; } 104 | double e21() const { return 0.0; } 105 | double e22() const { return 1.0; } 106 | double e23() const { return 0.0; } 107 | 108 | double e30() const { return x; } 109 | double e31() const { return y; } 110 | double e32() const { return z; } 111 | double e33() const { return 1.0; } 112 | 113 | static const Constancy c00 = ConstantOne; 114 | static const Constancy c01 = ConstantZero; 115 | static const Constancy c02 = ConstantZero; 116 | static const Constancy c03 = ConstantZero; 117 | 118 | static const Constancy c10 = ConstantZero; 119 | static const Constancy c11 = ConstantOne; 120 | static const Constancy c12 = ConstantZero; 121 | static const Constancy c13 = ConstantZero; 122 | 123 | static const Constancy c20 = ConstantZero; 124 | static const Constancy c21 = ConstantZero; 125 | static const Constancy c22 = ConstantOne; 126 | static const Constancy c23 = ConstantZero; 127 | 128 | static const Constancy c30 = NotConstant; 129 | static const Constancy c31 = NotConstant; 130 | static const Constancy c32 = NotConstant; 131 | static const Constancy c33 = ConstantOne; 132 | 133 | }; 134 | 135 | struct InverseTranslation : 136 | public Base 137 | { 138 | InverseTranslation() 139 | { 140 | // uninitialized 141 | } 142 | 143 | 144 | InverseTranslation(double iX, double iY, double iZ) 145 | : x(iX) 146 | , y(iY) 147 | , z(iZ) 148 | {} 149 | 150 | template 151 | InverseTranslation(const UserTypeT &iValue) 152 | : x(TranslateValuesFrom::x(iValue)) 153 | , y(TranslateValuesFrom::y(iValue)) 154 | , z(TranslateValuesFrom::z(iValue)) 155 | {} 156 | 157 | double x; 158 | double y; 159 | double z; 160 | 161 | static const InverseProvision inverseProvision = InverseProvided; 162 | typedef Translation InverseType; 163 | InverseType inverse() const { return InverseType(x, y, z); } 164 | 165 | 166 | double e00() const { return 1.0; } 167 | double e01() const { return 0.0; } 168 | double e02() const { return 0.0; } 169 | double e03() const { return 0.0; } 170 | 171 | double e10() const { return 0.0; } 172 | double e11() const { return 1.0; } 173 | double e12() const { return 0.0; } 174 | double e13() const { return 0.0; } 175 | 176 | double e20() const { return 0.0; } 177 | double e21() const { return 0.0; } 178 | double e22() const { return 1.0; } 179 | double e23() const { return 0.0; } 180 | 181 | double e30() const { return -x; } 182 | double e31() const { return -y; } 183 | double e32() const { return -z; } 184 | double e33() const { return 1.0; } 185 | 186 | static const Constancy c00 = ConstantOne; 187 | static const Constancy c01 = ConstantZero; 188 | static const Constancy c02 = ConstantZero; 189 | static const Constancy c03 = ConstantZero; 190 | 191 | static const Constancy c10 = ConstantZero; 192 | static const Constancy c11 = ConstantOne; 193 | static const Constancy c12 = ConstantZero; 194 | static const Constancy c13 = ConstantZero; 195 | 196 | static const Constancy c20 = ConstantZero; 197 | static const Constancy c21 = ConstantZero; 198 | static const Constancy c22 = ConstantOne; 199 | static const Constancy c23 = ConstantZero; 200 | 201 | static const Constancy c30 = NotConstant; 202 | static const Constancy c31 = NotConstant; 203 | static const Constancy c32 = NotConstant; 204 | static const Constancy c33 = ConstantOne; 205 | }; 206 | 207 | 208 | Translation::InverseType 209 | Translation::inverse() const 210 | { 211 | return InverseType(x, y, z); 212 | } 213 | 214 | } // namespace xbb 215 | 216 | #endif // XBB_TRANSLATION_H 217 | -------------------------------------------------------------------------------- /include/xbb/Transpose.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #ifndef XBB_TRANSPOSE_H 30 | #define XBB_TRANSPOSE_H 31 | 32 | #include "Base.h" 33 | #include "ReducedMatrix.h" 34 | 35 | namespace xbb { 36 | 37 | template struct Transpose; 38 | 39 | template < 40 | InverseProvision InverseT, 41 | typename TransformT> 42 | struct TransposeInverseProvider 43 | { 44 | static const InverseProvision inverseProvision = InverseDeprived; 45 | }; 46 | 47 | template 48 | struct TransposeInverseProvider 49 | { 50 | static const InverseProvision inverseProvision = InverseProvided; 51 | 52 | typedef Transpose InverseType; 53 | 54 | InverseType 55 | inverse() const 56 | { 57 | typedef Transpose Derived; 58 | const Derived & d = static_cast(*this); 59 | 60 | return InverseType(d.transform.inverse()); 61 | } 62 | }; 63 | 64 | 65 | template 66 | struct Transpose 67 | : public Base > 68 | , public TransposeInverseProvider 69 | { 70 | Transpose() 71 | { 72 | // uninitialized 73 | } 74 | 75 | Transpose(const TransformT &aTransform) 76 | : transform(aTransform) 77 | { 78 | } 79 | 80 | TransformT transform; 81 | 82 | TransformT 83 | transpose() const 84 | { 85 | return transform; 86 | } 87 | 88 | // transposed constancy 89 | static const Constancy c00 = TransformT::c00; 90 | static const Constancy c01 = TransformT::c10; 91 | static const Constancy c02 = TransformT::c20; 92 | static const Constancy c03 = TransformT::c30; 93 | 94 | static const Constancy c10 = TransformT::c01; 95 | static const Constancy c11 = TransformT::c11; 96 | static const Constancy c12 = TransformT::c21; 97 | static const Constancy c13 = TransformT::c31; 98 | 99 | static const Constancy c20 = TransformT::c02; 100 | static const Constancy c21 = TransformT::c12; 101 | static const Constancy c22 = TransformT::c22; 102 | static const Constancy c23 = TransformT::c32; 103 | 104 | static const Constancy c30 = TransformT::c03; 105 | static const Constancy c31 = TransformT::c13; 106 | static const Constancy c32 = TransformT::c23; 107 | static const Constancy c33 = TransformT::c33; 108 | 109 | typedef ReducedMatrix 110 | < 111 | c00, c01, c02, c03, 112 | c10, c11, c12, c13, 113 | c20, c21, c22, c23, 114 | c30, c31, c32, c33 115 | > ReducedType; 116 | 117 | ReducedType reduce() const 118 | { 119 | const auto t = transform.reduce(); 120 | 121 | ReducedType r; 122 | 123 | r.template setByTranspose<0,0>(t); 124 | r.template setByTranspose<0,1>(t); 125 | r.template setByTranspose<0,2>(t); 126 | r.template setByTranspose<0,3>(t); 127 | 128 | r.template setByTranspose<1,0>(t); 129 | r.template setByTranspose<1,1>(t); 130 | r.template setByTranspose<1,2>(t); 131 | r.template setByTranspose<1,3>(t); 132 | 133 | r.template setByTranspose<2,0>(t); 134 | r.template setByTranspose<2,1>(t); 135 | r.template setByTranspose<2,2>(t); 136 | r.template setByTranspose<2,3>(t); 137 | 138 | r.template setByTranspose<3,0>(t); 139 | r.template setByTranspose<3,1>(t); 140 | r.template setByTranspose<3,2>(t); 141 | r.template setByTranspose<3,3>(t); 142 | 143 | return r; 144 | } 145 | 146 | template 147 | void to(UserMatrixTypeT &aMat) const 148 | { 149 | const auto r = reduce(); 150 | 151 | MatrixValuesTo::e00(aMat, r.e00()); 152 | MatrixValuesTo::e01(aMat, r.e01()); 153 | MatrixValuesTo::e02(aMat, r.e02()); 154 | MatrixValuesTo::e03(aMat, r.e03()); 155 | 156 | MatrixValuesTo::e10(aMat, r.e10()); 157 | MatrixValuesTo::e11(aMat, r.e11()); 158 | MatrixValuesTo::e12(aMat, r.e12()); 159 | MatrixValuesTo::e13(aMat, r.e13()); 160 | 161 | MatrixValuesTo::e20(aMat, r.e20()); 162 | MatrixValuesTo::e21(aMat, r.e21()); 163 | MatrixValuesTo::e22(aMat, r.e22()); 164 | MatrixValuesTo::e23(aMat, r.e23()); 165 | 166 | MatrixValuesTo::e30(aMat, r.e30()); 167 | MatrixValuesTo::e31(aMat, r.e31()); 168 | MatrixValuesTo::e32(aMat, r.e32()); 169 | MatrixValuesTo::e33(aMat, r.e33()); 170 | } 171 | 172 | // To explicitly cast down to a 4x3 ignoring extra elements 173 | // versus requiring them to match Identity 174 | template 175 | void to4x3(UserMatrixTypeT &aMat) const 176 | { 177 | const auto r = reduce(); 178 | // Purposefully ignore d.e03(), d.e13(), d.e23(), d.e33() 179 | 180 | MatrixValuesTo::e00(aMat, r.e00()); 181 | MatrixValuesTo::e01(aMat, r.e01()); 182 | MatrixValuesTo::e02(aMat, r.e02()); 183 | 184 | MatrixValuesTo::e10(aMat, r.e10()); 185 | MatrixValuesTo::e11(aMat, r.e11()); 186 | MatrixValuesTo::e12(aMat, r.e12()); 187 | 188 | MatrixValuesTo::e20(aMat, r.e20()); 189 | MatrixValuesTo::e21(aMat, r.e21()); 190 | MatrixValuesTo::e22(aMat, r.e22()); 191 | 192 | MatrixValuesTo::e30(aMat, r.e30()); 193 | MatrixValuesTo::e31(aMat, r.e31()); 194 | MatrixValuesTo::e32(aMat, r.e32()); 195 | } 196 | 197 | // To explicitly cast down to a 3x3 ignoring extra elements 198 | // versus requiring them to match Identity 199 | template 200 | void to3x3(UserMatrixTypeT &aMat) const 201 | { 202 | const auto r = reduce(); 203 | // Purposefully ignore d.e03(), d.e13(), d.e23(), d.e30(), d.e31(), 204 | // d.e32(), d.e32(), d.e33() 205 | 206 | MatrixValuesTo::e00(aMat, r.e00()); 207 | MatrixValuesTo::e01(aMat, r.e01()); 208 | MatrixValuesTo::e02(aMat, r.e02()); 209 | 210 | MatrixValuesTo::e10(aMat, r.e10()); 211 | MatrixValuesTo::e11(aMat, r.e11()); 212 | MatrixValuesTo::e12(aMat, r.e12()); 213 | 214 | MatrixValuesTo::e20(aMat, r.e20()); 215 | MatrixValuesTo::e21(aMat, r.e21()); 216 | MatrixValuesTo::e22(aMat, r.e22()); 217 | } 218 | 219 | 220 | }; 221 | 222 | 223 | } // namespace xbb 224 | 225 | #endif // XBB_TRANSPOSE_H 226 | -------------------------------------------------------------------------------- /include/xbb/detail/ConstancyAccess.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_CONSTANCY_ACCESS_H 29 | #define XBB_DETAIL_CONSTANCY_ACCESS_H 30 | 31 | namespace xbb { 32 | namespace detail { 33 | 34 | // Use template specialization to access the correct static constancy enum 35 | // of a Transform 36 | template 37 | struct ConstancyAccess 38 | { 39 | //static const Constancy c; 40 | }; 41 | 42 | template 43 | struct ConstancyAccess<0, 0, T> 44 | { 45 | static const Constancy c = T::c00; 46 | }; 47 | template 48 | struct ConstancyAccess<0, 1, T> 49 | { 50 | static const Constancy c = T::c01; 51 | }; 52 | template 53 | struct ConstancyAccess<0, 2, T> 54 | { 55 | static const Constancy c = T::c02; 56 | }; 57 | 58 | template 59 | struct ConstancyAccess<0, 3, T> 60 | { 61 | static const Constancy c = T::c03; 62 | }; 63 | 64 | 65 | template 66 | struct ConstancyAccess<1, 0, T> 67 | { 68 | static const Constancy c = T::c10; 69 | }; 70 | template 71 | struct ConstancyAccess<1, 1, T> 72 | { 73 | static const Constancy c = T::c11; 74 | }; 75 | template 76 | struct ConstancyAccess<1, 2, T> 77 | { 78 | static const Constancy c = T::c12; 79 | }; 80 | 81 | template 82 | struct ConstancyAccess<1, 3, T> 83 | { 84 | static const Constancy c = T::c13; 85 | }; 86 | 87 | template 88 | struct ConstancyAccess<2, 0, T> 89 | { 90 | static const Constancy c = T::c20; 91 | }; 92 | template 93 | struct ConstancyAccess<2, 1, T> 94 | { 95 | static const Constancy c = T::c21; 96 | }; 97 | template 98 | struct ConstancyAccess<2, 2, T> 99 | { 100 | static const Constancy c = T::c22; 101 | }; 102 | 103 | template 104 | struct ConstancyAccess<2, 3, T> 105 | { 106 | static const Constancy c = T::c23; 107 | }; 108 | 109 | template 110 | struct ConstancyAccess<3, 0, T> 111 | { 112 | static const Constancy c = T::c30; 113 | }; 114 | template 115 | struct ConstancyAccess<3, 1, T> 116 | { 117 | static const Constancy c = T::c31; 118 | }; 119 | template 120 | struct ConstancyAccess<3, 2, T> 121 | { 122 | static const Constancy c = T::c32; 123 | }; 124 | 125 | template 126 | struct ConstancyAccess<3, 3, T> 127 | { 128 | static const Constancy c = T::c33; 129 | }; 130 | 131 | } // namespace detail 132 | } // namespace 133 | 134 | #endif // XBB_DETAIL_CONSTANCY_ACCESS_H 135 | -------------------------------------------------------------------------------- /include/xbb/detail/ConstancyByMatrixMultiply.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_CONSTANCY_BY_MATRIX_MULTIPLY_H 29 | #define XBB_DETAIL_CONSTANCY_BY_MATRIX_MULTIPLY_H 30 | 31 | #include "ConstancyAccess.h" 32 | #include "ConstancyThroughAddition.h" 33 | #include "ConstancyThroughMultiplication.h" 34 | 35 | namespace xbb { 36 | namespace detail { 37 | 38 | template< 39 | Constancy M0LT, Constancy M0RT, 40 | Constancy M1LT, Constancy M1RT, 41 | Constancy M2LT, Constancy M2RT, 42 | Constancy M3LT, Constancy M3RT 43 | > 44 | struct ConstancyThrough4MultipliesAnd3Adds 45 | { 46 | static const Constancy c = 47 | ConstancyThroughAddition 48 | < 49 | ConstancyThroughAddition 50 | < 51 | ConstancyThroughAddition 52 | < 53 | ConstancyThroughMultiplication::c 54 | , 55 | ConstancyThroughMultiplication::c 56 | >::c 57 | , 58 | ConstancyThroughMultiplication::c 59 | >::c 60 | , 61 | ConstancyThroughMultiplication::c 62 | >::c; 63 | }; 64 | 65 | template 67 | struct ConstancyByMatrixMultiply 68 | { 69 | static const Constancy c = 70 | ConstancyThrough4MultipliesAnd3Adds< 71 | ConstancyAccess::c, ConstancyAccess<0, RightColT, RightT>::c, 72 | ConstancyAccess::c, ConstancyAccess<1, RightColT, RightT>::c, 73 | ConstancyAccess::c, ConstancyAccess<2, RightColT, RightT>::c, 74 | ConstancyAccess::c, ConstancyAccess<3, RightColT, RightT>::c 75 | >::c; 76 | }; 77 | 78 | } // namespace detail 79 | } // namespace 80 | 81 | #endif // XBB_DETAIL_CONSTANCY_BY_MATRIX_MULTIPLY_H 82 | -------------------------------------------------------------------------------- /include/xbb/detail/ConstancyThroughAddition.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_CONSTANCY_THROUGH_ADDITION_H 29 | #define XBB_DETAIL_CONSTANCY_THROUGH_ADDITION_H 30 | 31 | namespace xbb { 32 | namespace detail { 33 | 34 | // Use template specialization to specify the constancy when two 35 | // values are added together 36 | template 37 | struct ConstancyThroughAddition 38 | {}; 39 | 40 | template<> 41 | struct ConstancyThroughAddition 42 | { static const Constancy c = ConstantZero; }; 43 | 44 | template<> 45 | struct ConstancyThroughAddition 46 | { static const Constancy c = ConstantOne; }; 47 | 48 | template<> 49 | struct ConstancyThroughAddition 50 | { static const Constancy c = NotConstant; }; 51 | 52 | 53 | template<> 54 | struct ConstancyThroughAddition 55 | { static const Constancy c = ConstantOne; }; 56 | 57 | template<> 58 | struct ConstancyThroughAddition 59 | { static const Constancy c = NotConstant; }; 60 | 61 | template<> 62 | struct ConstancyThroughAddition 63 | { static const Constancy c = NotConstant; }; 64 | 65 | template<> 66 | struct ConstancyThroughAddition 67 | { static const Constancy c = NotConstant; }; 68 | 69 | template<> 70 | struct ConstancyThroughAddition 71 | { static const Constancy c = NotConstant; }; 72 | 73 | template<> 74 | struct ConstancyThroughAddition 75 | { static const Constancy c = NotConstant; }; 76 | 77 | } // namespace detail 78 | } // namespace 79 | 80 | #endif // XBB_DETAIL_CONSTANCY_THROUGH_ADDITION_H 81 | -------------------------------------------------------------------------------- /include/xbb/detail/ConstancyThroughMultiplication.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_CONSTANCY_THROUGH_MULTIPLICATION_H 29 | #define XBB_DETAIL_CONSTANCY_THROUGH_MULTIPLICATION_H 30 | 31 | namespace xbb { 32 | namespace detail { 33 | 34 | // Use template specialization to specify the constancy when two 35 | // values are multiplied 36 | template 37 | struct ConstancyThroughMultiplication 38 | {}; 39 | 40 | template<> 41 | struct ConstancyThroughMultiplication 42 | { static const Constancy c = ConstantZero; }; 43 | 44 | template<> 45 | struct ConstancyThroughMultiplication 46 | { static const Constancy c = ConstantZero; }; 47 | 48 | template<> 49 | struct ConstancyThroughMultiplication 50 | { static const Constancy c = ConstantZero; }; 51 | 52 | 53 | template<> 54 | struct ConstancyThroughMultiplication 55 | { static const Constancy c = ConstantZero; }; 56 | 57 | template<> 58 | struct ConstancyThroughMultiplication 59 | { static const Constancy c = ConstantOne; }; 60 | 61 | template<> 62 | struct ConstancyThroughMultiplication 63 | { static const Constancy c = NotConstant; }; 64 | 65 | template<> 66 | struct ConstancyThroughMultiplication 67 | { static const Constancy c = ConstantZero; }; 68 | 69 | template<> 70 | struct ConstancyThroughMultiplication 71 | { static const Constancy c = NotConstant; }; 72 | 73 | template<> 74 | struct ConstancyThroughMultiplication 75 | { static const Constancy c = NotConstant; }; 76 | 77 | 78 | } // namespace detail 79 | } // namespace 80 | 81 | #endif // XBB_DETAIL_CONSTANCY_THROUGH_MULTIPLICATION_H 82 | -------------------------------------------------------------------------------- /include/xbb/detail/ElementMultiplier.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_ELEMENT_MULTIPLIER_H 29 | #define XBB_DETAIL_ELEMENT_MULTIPLIER_H 30 | 31 | #include "../Constancy.h" 32 | #include "ElementProduct.h" 33 | 34 | 35 | namespace xbb { 36 | namespace detail { 37 | 38 | 39 | // Access left and right elements and multply them together into ElementProduct 40 | // However the elements themselves may be constants or non constant 41 | // So provide specializations to handle all combinations and produce a correctly 42 | // typed ElementProduct that is constant or not constant as needed 43 | template 44 | struct ElementMultiplier 45 | { 46 | template 47 | static ElementProduct mul(const LeftT & iLeft, const RightT &iRight) 48 | { 49 | ElementProduct p; 50 | p.mValue = iLeft.template e()*iRight.template e(); 51 | return p; 52 | } 53 | }; 54 | 55 | template<> 56 | struct ElementMultiplier 57 | { 58 | template 59 | static ElementProduct mul(const LeftT &, const RightT &) 60 | { 61 | return ElementProduct(); 62 | } 63 | }; 64 | 65 | template<> 66 | struct ElementMultiplier 67 | { 68 | template 69 | static ElementProduct mul(const LeftT &, const RightT &) 70 | { 71 | return ElementProduct(); 72 | } 73 | }; 74 | 75 | template<> 76 | struct ElementMultiplier 77 | { 78 | template 79 | static ElementProduct mul(const LeftT &, const RightT &) 80 | { 81 | return ElementProduct(); 82 | } 83 | }; 84 | 85 | template<> 86 | struct ElementMultiplier 87 | { 88 | template 89 | static ElementProduct mul(const LeftT &, const RightT &) 90 | { 91 | return ElementProduct(); 92 | } 93 | }; 94 | 95 | template<> 96 | struct ElementMultiplier 97 | { 98 | template 99 | static ElementProduct mul(const LeftT &, const RightT &) 100 | { 101 | return ElementProduct(); 102 | } 103 | }; 104 | 105 | template<> 106 | struct ElementMultiplier 107 | { 108 | template 109 | static ElementProduct mul(const LeftT &, const RightT &iRight) 110 | { 111 | ElementProduct p; 112 | p.mValue = iRight.template e(); 113 | return p; 114 | } 115 | }; 116 | 117 | template<> 118 | struct ElementMultiplier 119 | { 120 | template 121 | static ElementProduct mul(const LeftT &, const RightT &) 122 | { 123 | return ElementProduct(); 124 | } 125 | }; 126 | 127 | template<> 128 | struct ElementMultiplier 129 | { 130 | template 131 | static ElementProduct mul(const LeftT &iLeft, const RightT &) 132 | { 133 | ElementProduct p; 134 | p.mValue = iLeft.template e(); 135 | return p; 136 | } 137 | }; 138 | 139 | } // namespace detail 140 | } // namespace xbb 141 | 142 | 143 | #endif // XBB_DETAIL_ELEMENT_MULTIPLIER_H 144 | -------------------------------------------------------------------------------- /include/xbb/detail/ElementProduct.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_ELEMENT_PRODUCT_H 29 | #define XBB_DETAIL_ELEMENT_PRODUCT_H 30 | 31 | #include "../Constancy.h" 32 | 33 | 34 | namespace xbb { 35 | namespace detail { 36 | 37 | // To hold the result of an ElementMultiplier, 38 | // the ElementProduct has to model constant and nonconstant results 39 | // and support adding other ElementProducts to produce another ElementProduct 40 | template 41 | struct ElementProduct 42 | { 43 | }; 44 | 45 | template<> 46 | struct ElementProduct 47 | { 48 | ElementProduct() {} 49 | ElementProduct(double iValue) 50 | : mValue(iValue) 51 | {} 52 | 53 | const ElementProduct & add(const ElementProduct &) const 54 | { 55 | return *this; 56 | } 57 | ElementProduct add(const ElementProduct &) const 58 | { 59 | return ElementProduct(mValue + 1.0); 60 | } 61 | ElementProduct add(const ElementProduct & iOther) const 62 | { 63 | return ElementProduct(mValue + iOther.mValue); 64 | } 65 | 66 | double mValue; 67 | 68 | double value() const { return mValue; } 69 | }; 70 | 71 | template<> 72 | struct ElementProduct 73 | { 74 | template 75 | const ElementProduct & add(const ElementProduct & iOther) const 76 | { 77 | return iOther; 78 | } 79 | double value() const { return 0.0; } 80 | }; 81 | 82 | template<> 83 | struct ElementProduct 84 | { 85 | const ElementProduct & add(const ElementProduct &) const 86 | { 87 | return *this; 88 | } 89 | ElementProduct add(const ElementProduct &) const 90 | { 91 | return ElementProduct(2.0); 92 | } 93 | ElementProduct add(const ElementProduct &iOther) const 94 | { 95 | return ElementProduct(iOther.mValue + 1.0); 96 | } 97 | 98 | double value() const { return 1.0; } 99 | 100 | }; 101 | 102 | 103 | 104 | } // namespace detail 105 | } // namespace xbb 106 | 107 | 108 | #endif // XBB_DETAIL_ELEMENT_PRODUCT_H 109 | -------------------------------------------------------------------------------- /include/xbb/detail/Entry.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_ENTRY_H 29 | #define XBB_DETAIL_ENTRY_H 30 | 31 | #include "../Constancy.h" 32 | 33 | namespace xbb { 34 | namespace detail { 35 | 36 | // Entries in a ReducedMatrix can be constant values or not a constant 37 | // We use templates to uniquely identify the Row and Column of the matrix entry 38 | template 39 | struct Entry 40 | {}; 41 | 42 | template 43 | struct Entry 44 | { 45 | void set(double) {} 46 | double value() const { return 0.0; } 47 | }; 48 | 49 | template 50 | struct Entry 51 | { 52 | void set(double) {} 53 | double value() const { return 1.0; } 54 | }; 55 | 56 | template 57 | struct Entry 58 | { 59 | double mValue; 60 | void set(double iValue) { mValue = iValue;} 61 | double value() const { return mValue; } 62 | }; 63 | 64 | } // namespace detail 65 | } // namespace xbb 66 | 67 | 68 | #endif // XBB_DETAIL_ENTRY_H 69 | -------------------------------------------------------------------------------- /include/xbb/detail/IsSameType.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_IS_SAME_TYPE_H 29 | #define XBB_DETAIL_IS_SAME_TYPE_H 30 | 31 | // Although std::is_same() could be used, it is a C++11 library feature 32 | // and we want to support c++11 compilers perhaps without a C++11 library 33 | // so we will have our own helper class 34 | 35 | namespace xbb { 36 | namespace detail { 37 | 38 | // Entries in a ReducedMatrix can be constant values or not a constant 39 | // We use templates to uniquely identify the Row and Column of the matrix entry 40 | template 41 | struct IsSameType 42 | { 43 | static const bool value = false; 44 | }; 45 | 46 | template 47 | struct IsSameType 48 | { 49 | static const bool value = true; 50 | }; 51 | 52 | } // namespace detail 53 | } // namespace xbb 54 | 55 | 56 | #endif // XBB_DETAIL_IS_SAME_TYPE_H 57 | -------------------------------------------------------------------------------- /include/xbb/detail/NotConstantIfSheared.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_DETAIL_NOT_CONSTANT_IF_SHEARED_H 29 | #define XBB_DETAIL_NOT_CONSTANT_IF_SHEARED_H 30 | 31 | #include "../Constancy.h" 32 | 33 | namespace xbb { 34 | namespace detail { 35 | 36 | 37 | template 38 | struct NotConstantIfSheared { 39 | static const xbb::Constancy c = xbb::ConstantZero; 40 | }; 41 | 42 | // When the RowT == FixedAxisT and ColT = ShearedAxisT the 43 | // matrix element will be the shear factor, and will be NotConstant 44 | template 45 | struct NotConstantIfSheared { 46 | static const xbb::Constancy c = xbb::NotConstant; 47 | }; 48 | 49 | } // namespace detail 50 | } // namespace 51 | 52 | #endif // XBB_DETAIL_NOT_CONSTANT_IF_SHEARED_H 53 | -------------------------------------------------------------------------------- /unittest/AdaptRefToXbb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef ADAPT_REF_TO_XBB_H 29 | #define ADAPT_REF_TO_XBB_H 30 | 31 | #include "ref/Matrix4x4.h" 32 | #include "ref/Vec3.h" 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | // You can adapt existing math libraries to interact with xbb transforms 39 | // Just specialize the From and To templates for the user's type 40 | namespace xbb { 41 | 42 | template <> 43 | struct MatrixValuesFrom 44 | { 45 | static double e00(const ref::Matrix4x4 & iFrom) 46 | { 47 | return iFrom.e00(); 48 | } 49 | static double e01(const ref::Matrix4x4 & iFrom) 50 | { 51 | return iFrom.e01(); 52 | } 53 | static double e02(const ref::Matrix4x4 & iFrom) 54 | { 55 | return iFrom.e02(); 56 | } 57 | 58 | static double e03(const ref::Matrix4x4 & iFrom) 59 | { 60 | return iFrom.e03(); 61 | } 62 | 63 | static double e10(const ref::Matrix4x4 & iFrom) 64 | { 65 | return iFrom.e10(); 66 | } 67 | static double e11(const ref::Matrix4x4 & iFrom) 68 | { 69 | return iFrom.e11(); 70 | } 71 | static double e12(const ref::Matrix4x4 & iFrom) 72 | { 73 | return iFrom.e12(); 74 | } 75 | 76 | static double e13(const ref::Matrix4x4 & iFrom) 77 | { 78 | return iFrom.e13(); 79 | } 80 | 81 | static double e20(const ref::Matrix4x4 & iFrom) 82 | { 83 | return iFrom.e20(); 84 | } 85 | static double e21(const ref::Matrix4x4 & iFrom) 86 | { 87 | return iFrom.e21(); 88 | } 89 | static double e22(const ref::Matrix4x4 & iFrom) 90 | { 91 | return iFrom.e22(); 92 | } 93 | 94 | static double e23(const ref::Matrix4x4 & iFrom) 95 | { 96 | return iFrom.e23(); 97 | } 98 | 99 | static double e30(const ref::Matrix4x4 & iFrom) 100 | { 101 | return iFrom.e30(); 102 | } 103 | static double e31(const ref::Matrix4x4 & iFrom) 104 | { 105 | return iFrom.e31(); 106 | } 107 | static double e32(const ref::Matrix4x4 & iFrom) 108 | { 109 | return iFrom.e32(); 110 | } 111 | static double e33(const ref::Matrix4x4 & iFrom) 112 | { 113 | return iFrom.e33(); 114 | } 115 | }; 116 | 117 | template <> 118 | struct MatrixValuesTo 119 | { 120 | static void e00(ref::Matrix4x4 & iTo, double iValue) 121 | { 122 | iTo.m[0][0] = iValue; 123 | } 124 | static void e01(ref::Matrix4x4 & iTo, double iValue) 125 | { 126 | iTo.m[0][1] = iValue; 127 | } 128 | static void e02(ref::Matrix4x4 & iTo, double iValue) 129 | { 130 | iTo.m[0][2] = iValue; 131 | } 132 | 133 | static void e03(ref::Matrix4x4 & iTo, double iValue) 134 | { 135 | iTo.m[0][3] = iValue; 136 | } 137 | 138 | static void e10(ref::Matrix4x4 & iTo, double iValue) 139 | { 140 | iTo.m[1][0] = iValue; 141 | } 142 | static void e11(ref::Matrix4x4 & iTo, double iValue) 143 | { 144 | iTo.m[1][1] = iValue; 145 | } 146 | static void e12(ref::Matrix4x4 & iTo, double iValue) 147 | { 148 | iTo.m[1][2] = iValue; 149 | } 150 | 151 | static void e13(ref::Matrix4x4 & iTo, double iValue) 152 | { 153 | iTo.m[1][3] = iValue; 154 | } 155 | 156 | static void e20(ref::Matrix4x4 & iTo, double iValue) 157 | { 158 | iTo.m[2][0]= iValue; 159 | } 160 | static void e21(ref::Matrix4x4 & iTo, double iValue) 161 | { 162 | iTo.m[2][1] = iValue; 163 | } 164 | static void e22(ref::Matrix4x4 & iTo, double iValue) 165 | { 166 | iTo.m[2][2] = iValue; 167 | } 168 | 169 | static void e23(ref::Matrix4x4 & iTo, double iValue) 170 | { 171 | iTo.m[2][3] = iValue; 172 | } 173 | 174 | static void e30(ref::Matrix4x4 & iTo, double iValue) 175 | { 176 | iTo.m[3][0] = iValue; 177 | } 178 | static void e31(ref::Matrix4x4 & iTo, double iValue) 179 | { 180 | iTo.m[3][1] = iValue; 181 | } 182 | static void e32(ref::Matrix4x4 & iTo, double iValue) 183 | { 184 | iTo.m[3][2] = iValue; 185 | } 186 | static void e33(ref::Matrix4x4 & iTo, double iValue) 187 | { 188 | iTo.m[3][3] = iValue; 189 | } 190 | }; 191 | 192 | template <> 193 | struct ScaleValuesFrom 194 | { 195 | static double x(const ref::Vec3 & iFrom) 196 | { 197 | return iFrom.m[0]; 198 | } 199 | static double y(const ref::Vec3 & iFrom) 200 | { 201 | return iFrom.m[1]; 202 | } 203 | static double z(const ref::Vec3 & iFrom) 204 | { 205 | return iFrom.m[2]; 206 | } 207 | }; 208 | 209 | 210 | template <> 211 | struct Shear3ValuesFrom 212 | { 213 | static double x(const ref::Vec3 & iFrom) 214 | { 215 | return iFrom.m[0]; 216 | } 217 | static double y(const ref::Vec3 & iFrom) 218 | { 219 | return iFrom.m[1]; 220 | } 221 | static double z(const ref::Vec3 & iFrom) 222 | { 223 | return iFrom.m[2]; 224 | } 225 | }; 226 | 227 | template <> 228 | struct TranslateValuesFrom 229 | { 230 | static double x(const ref::Vec3 & iFrom) 231 | { 232 | return iFrom.m[0]; 233 | } 234 | static double y(const ref::Vec3 & iFrom) 235 | { 236 | return iFrom.m[1]; 237 | } 238 | static double z(const ref::Vec3 & iFrom) 239 | { 240 | return iFrom.m[2]; 241 | } 242 | }; 243 | 244 | } // namespace xbb 245 | 246 | #endif // ADAPT_REF_TO_XBB_H 247 | -------------------------------------------------------------------------------- /unittest/AdaptersWork.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | 35 | #include "ref/Matrix4x4.h" 36 | #include "ref/Vec3.h" 37 | #include "AdaptRefToXbb.h" 38 | #include "FloatingPointComparisons.h" 39 | #include "TestValues.h" 40 | #include "TransformsAreClose.h" 41 | 42 | 43 | using namespace xbb; 44 | 45 | 46 | static const char * sAdaptatersWorkName = "Adapters Work"; 47 | TEST_CASE(sAdaptatersWorkName, "") 48 | { 49 | 50 | { 51 | ref::Matrix4x4 rMat; 52 | rMat.m[0][0] = 100; 53 | rMat.m[0][1] = 110; 54 | rMat.m[0][2] = 120; 55 | rMat.m[0][3] = 130; 56 | 57 | rMat.m[1][0] = 101; 58 | rMat.m[1][1] = 111; 59 | rMat.m[1][2] = 121; 60 | rMat.m[1][3] = 131; 61 | 62 | rMat.m[2][0] = 102; 63 | rMat.m[2][1] = 112; 64 | rMat.m[2][2] = 122; 65 | rMat.m[2][3] = 132; 66 | 67 | rMat.m[3][0] = 103; 68 | rMat.m[3][1] = 113; 69 | rMat.m[3][2] = 123; 70 | rMat.m[3][3] = 133; 71 | 72 | xbb::Matrix4x4 xMat(rMat); 73 | 74 | TRANSFORMS_ARE_CLOSE(xMat, rMat); 75 | 76 | ref::Matrix4x4 rMat2; 77 | xMat.to(rMat2); 78 | 79 | TRANSFORMS_ARE_CLOSE(xMat, rMat2); 80 | } 81 | 82 | { 83 | ref::Vec3 rVec(1.0, 2.0, 3.0); 84 | xbb::Scale xScale(rVec); 85 | REQUIRE(isEqual(rVec.x(), xScale.x)); 86 | REQUIRE(isEqual(rVec.y(), xScale.y)); 87 | REQUIRE(isEqual(rVec.z(), xScale.z)); 88 | } 89 | 90 | { 91 | ref::Vec3 rVec(1.0, 2.0, 3.0); 92 | xbb::Translation xTrans(rVec); 93 | REQUIRE(isEqual(rVec.x(), xTrans.x)); 94 | REQUIRE(isEqual(rVec.y(), xTrans.y)); 95 | REQUIRE(isEqual(rVec.z(), xTrans.z)); 96 | } 97 | 98 | { 99 | ref::Vec3 rVec(1.0, 2.0, 3.0); 100 | xbb::Shear3 xShear(rVec); 101 | REQUIRE(isEqual(rVec.x(), xShear.x)); 102 | REQUIRE(isEqual(rVec.y(), xShear.y)); 103 | REQUIRE(isEqual(rVec.z(), xShear.z)); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /unittest/CATCH/LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /unittest/CATCH/README.md: -------------------------------------------------------------------------------- 1 | ![catch logo](catch-logo-small.png) 2 | 3 | *v1.0 build 43 (master branch)* 4 | 5 | Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) 6 | 7 | [Please see this page if you are updating from a version before 1.0](docs/whats-changed.md) 8 | 9 | ## What's the Catch? 10 | 11 | Catch stands for C++ Automated Test Cases in Headers and is a multi-paradigm automated test framework for C++ and Objective-C (and, maybe, C). It is implemented entirely in a set of header files, but is packaged up as a single header for extra convenience. 12 | 13 | ## How to use it 14 | This documentation comprises these three parts: 15 | 16 | * [Why do we need yet another C++ Test Framework?](docs/why-catch.md) 17 | * [Tutorial](docs/tutorial.md) - getting started 18 | * [Reference section](docs/reference-index.md) - all the details 19 | 20 | The documentation will continue until morale improves 21 | 22 | ## More 23 | * Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/philsquared/Catch/issues) 24 | * For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum) 25 | -------------------------------------------------------------------------------- /unittest/EliminateIdentityFromMultiplication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | 35 | 36 | using namespace xbb; 37 | 38 | 39 | TEST_CASE("Elimination of Identity from Multiplication") 40 | { 41 | // When multiplying transforms together, Identity should disappear 42 | 43 | xbb::Identity I; 44 | xbb::Translation T; 45 | xbb::Scale S; 46 | xbb::Shear3 SH; 47 | xbb::RotationX Rx; 48 | xbb::RotationY Ry; 49 | xbb::RotationZ Rz; 50 | 51 | // Require identity to quietly disappear from multiplication chains 52 | { 53 | auto result = T*I; 54 | REQUIRE(result.is() == false) ; 55 | REQUIRE(result.is() == true); 56 | } 57 | 58 | { 59 | auto result = I*T; 60 | REQUIRE(result.is() == false) ; 61 | REQUIRE(result.is() == true); 62 | } 63 | 64 | { 65 | auto result = S*I; 66 | REQUIRE(result.is() == false) ; 67 | REQUIRE(result.is() == true); 68 | } 69 | 70 | { 71 | auto result = I*S; 72 | REQUIRE(result.is() == false) ; 73 | REQUIRE(result.is() == true); 74 | } 75 | 76 | { 77 | auto result = SH*I; 78 | REQUIRE(result.is() == false) ; 79 | REQUIRE(result.is() == true); 80 | } 81 | 82 | { 83 | auto result = I*SH; 84 | REQUIRE(result.is() == false) ; 85 | REQUIRE(result.is() == true); 86 | } 87 | 88 | { 89 | auto result = Rx*I; 90 | REQUIRE(result.is() == false) ; 91 | REQUIRE(result.is() == true); 92 | } 93 | 94 | { 95 | auto result = I*Rx; 96 | REQUIRE(result.is() == false) ; 97 | REQUIRE(result.is() == true); 98 | } 99 | 100 | { 101 | auto result = Ry*I; 102 | REQUIRE(result.is() == false) ; 103 | REQUIRE(result.is() == true); 104 | } 105 | 106 | { 107 | auto result = I*Ry; 108 | REQUIRE(result.is() == false) ; 109 | REQUIRE(result.is() == true); 110 | } 111 | 112 | { 113 | auto result = I*S*SH; 114 | REQUIRE(result.is() == false) ; 115 | REQUIRE(result.is() == true); 116 | } 117 | 118 | { 119 | auto result = S*SH*I; 120 | REQUIRE(result.is() == false) ; 121 | REQUIRE(result.is() == true); 122 | } 123 | 124 | { 125 | auto result = S*I*SH; 126 | REQUIRE(result.is() == false) ; 127 | REQUIRE(result.is() == true); 128 | } 129 | 130 | { 131 | auto result = S*SH*I*Rz*Ry*Rz*I*T; 132 | REQUIRE(result.is() == false) ; 133 | REQUIRE(result.is() == true); 134 | } 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /unittest/FloatingPointComparisons.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_UNITTEST_FLOATING_POINT_COMPARISONS_H 29 | #define XBB_UNITTEST_FLOATING_POINT_COMPARISONS_H 30 | 31 | #ifndef XBB_UNITTEST_DEFAULT_RELATIVE_PERCENTAGE 32 | #define XBB_UNITTEST_DEFAULT_RELATIVE_PERCENTAGE 0.0005 33 | #endif 34 | 35 | #ifndef XBB_UNITTEST_DEFAULT_ABS_TOLERANCE 36 | #define XBB_UNITTEST_DEFAULT_ABS_TOLERANCE 0.000001 37 | #endif 38 | 39 | #include 40 | 41 | inline 42 | bool isRelOrAbsEqual(double a, double b, double relativePercentage = XBB_UNITTEST_DEFAULT_RELATIVE_PERCENTAGE, double abs = XBB_UNITTEST_DEFAULT_ABS_TOLERANCE) 43 | { 44 | if(fabs(a - b) < abs) 45 | return true; 46 | 47 | double relative; 48 | if(fabs(a) > fabs(b)) { 49 | relative = fabs((a-b)/a); 50 | } else { 51 | relative = fabs((a-b)/b); 52 | } 53 | return (relative <= relativePercentage); 54 | } 55 | 56 | inline 57 | bool isRelOrAbsEqual(float a, float b, float relativePercentage = XBB_UNITTEST_DEFAULT_RELATIVE_PERCENTAGE, float abs = XBB_UNITTEST_DEFAULT_ABS_TOLERANCE) 58 | { 59 | if(fabsf(a - b) < abs) 60 | return true; 61 | 62 | float relative; 63 | if(fabsf(a) > fabsf(b)) { 64 | relative = fabsf((a-b)/a); 65 | } else { 66 | relative = fabsf((a-b)/b); 67 | } 68 | return (relative <= relativePercentage); 69 | } 70 | 71 | 72 | 73 | template 74 | inline 75 | bool isEqual(T a, T b) 76 | { 77 | return (!(a > b) && !(a < b)); 78 | } 79 | 80 | 81 | template 82 | inline 83 | bool isClose(const T & a, const T & b) 84 | { 85 | return isRelOrAbsEqual(a, b, XBB_UNITTEST_DEFAULT_RELATIVE_PERCENTAGE, XBB_UNITTEST_DEFAULT_ABS_TOLERANCE); 86 | } 87 | 88 | template 89 | inline 90 | bool isExactly(const T & a, const T & b) 91 | { 92 | return isEqual(a, b); 93 | } 94 | 95 | 96 | #endif // XBB_UNITTEST_FLOATING_POINT_COMPARISONS_H 97 | -------------------------------------------------------------------------------- /unittest/InverseSxSH.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include "ref/Matrix4x4.h" 35 | #include "ScopedTimer.h" 36 | #include "TestValues.h" 37 | #include "TransformsAreClose.h" 38 | 39 | 40 | using namespace xbb; 41 | 42 | 43 | static const char * sInverseSxSHName = "Inverse S*SH"; 44 | TEST_CASE(sInverseSxSHName, "") 45 | { 46 | // time inverse S*SH with reference vs XBB 47 | 48 | volatile const TestValues tv = TestValues::get(); 49 | const int repeatCount = 1000000; 50 | 51 | // Compose a transform using traditional OO approach 52 | double refTime = 0.0; 53 | { 54 | ScopedTimer timer(refTime); 55 | XBB_INLINE_BLOCK 56 | { 57 | for (int rep=0; rep < repeatCount; ++rep) { 58 | ref::Matrix4x4 S; 59 | S.makeScale(tv.scaleX, tv.scaleY, tv.scaleZ); 60 | 61 | ref::Matrix4x4 SH; 62 | SH.makeShear3(tv.shearX, tv.shearY, tv.shearZ); 63 | 64 | *gRefFinalTransform = (S*SH).inverse(); 65 | } 66 | } 67 | } 68 | 69 | // Compose a transform using XBB 70 | xbb::Matrix4x3 xbbFinalTransform; 71 | double xbbTime = 0.0; 72 | { 73 | ScopedTimer timer(xbbTime); 74 | XBB_INLINE_BLOCK 75 | { 76 | for (int rep=0; rep < repeatCount; ++rep) { 77 | xbb::Scale S(tv.scaleX, tv.scaleY, tv.scaleZ); 78 | xbb::Shear3 SH(tv.shearX, tv.shearY, tv.shearZ); 79 | 80 | (S*SH).inverse().to(*gXbbFinalTransform); 81 | } 82 | } 83 | } 84 | 85 | 86 | std::cout << sInverseSxSHName << ":"<< std::endl; 87 | // std::cout << "Ref Transform " << gRefFinalTransform << std::endl; 88 | // std::cout << "xbb Transform " << gXbbFinalTransform << std::endl; 89 | TRANSFORMS_ARE_CLOSE(*gXbbFinalTransform, *gRefFinalTransform); 90 | 91 | std::cout << " ref Time " << refTime << std::endl; 92 | std::cout << " xbb Time " << xbbTime << std::endl; 93 | std::cout << " speedup " << refTime/xbbTime << "x" << std::endl << std::endl; 94 | } 95 | -------------------------------------------------------------------------------- /unittest/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, Intel Corporation 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # 6 | # * Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # * Redistributions in binary form must reproduce the above copyright 9 | # notice, this list of conditions and the following disclaimer in the 10 | # documentation and/or other materials provided with the distribution. 11 | # * Neither the name of Intel Corporation nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 19 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | #CXX=icpc 27 | #LD=icpc 28 | 29 | #CXX=/opt/rh/devtoolset-2/root/usr/bin/g++ 30 | #LD=/opt/rh/devtoolset-2/root/usr/bin/g++ 31 | CXX=g++ 32 | LD=g++ 33 | 34 | RM=rm -rf 35 | OUT_DIR=bin 36 | 37 | #if we have built previously then we would have generated dependency for each .o file in a .d 38 | AUTO_DEPS = $(shell find objs/ -type f -name '*.d') 39 | AUTO_DEPS_CPPFLAGS = -MMD -MP 40 | 41 | dir_guard= mkdir -p $(@D) 42 | 43 | DEBUG_CPPFLAGS = -DDEBUG -O0 -inline-level=0 44 | #VECREPORT_CPPFLAGS = -vec-report7 45 | VECREPORT_CPPFLAGS = -vec-report6 -mP2OPT_hpo_emit_align_diagnostic_for_cpu 46 | 47 | #-opt-report-phase hpo 48 | 49 | ICC_CPPFLAGS = $(AUTO_DEPS_CPPFLAGS) \ 50 | -isystem./ \ 51 | -I../include \ 52 | -std=c++0x \ 53 | -g \ 54 | -O3 \ 55 | -Iinclude \ 56 | -debug inline-debug-info \ 57 | -restrict \ 58 | -Wno-deprecated -w2 -Wall -Wremarks -Wcheck -wd191 -wd304 -wd383 \ 59 | -wd444 -wd981 -wd1418 -wd1875 -wd593 -wd177 -wd3218 -wd3346 -wd11074 -wd11076 \ 60 | -Qoption,cpp,--print_include_stack 61 | 62 | GCC_CPPFLAGS = $(AUTO_DEPS_CPPFLAGS) \ 63 | -isystem./ \ 64 | -I../include \ 65 | -std=c++0x \ 66 | -g \ 67 | -O3 \ 68 | -Iinclude \ 69 | -W \ 70 | -Wall \ 71 | -Wcast-align \ 72 | -Wswitch \ 73 | -Wno-unused-parameter \ 74 | -Wreorder \ 75 | -Wdisabled-optimization \ 76 | -Wno-system-headers 77 | 78 | #CPPFLAGS = $(ICC_CPPFLAGS) 79 | CPPFLAGS = $(GCC_CPPFLAGS) 80 | 81 | 82 | LDFLAGS = -g -lrt 83 | 84 | 85 | 86 | objs/%.o : %.cpp 87 | $(dir_guard) 88 | $(CXX) -c $(HOST_CPPFLAGS) $(CPPFLAGS) $< -o $@ 89 | 90 | OBJS = \ 91 | objs/main.o \ 92 | objs/AdaptersWork.o \ 93 | objs/BasicTransformsMatch.o \ 94 | objs/EliminateIdentityFromMultiplication.o \ 95 | objs/InversesMatch.o \ 96 | objs/InverseSxSH.o \ 97 | objs/PartialPrecomputedSxSHxRxT.o \ 98 | objs/PrecomputedSxSHxRxT.o \ 99 | objs/StandardSxSHxRxT.o \ 100 | objs/StandardSxSHxPSxPSHxRxIPSHxIPSxTxP.o \ 101 | objs/TestValues.o \ 102 | objs/TypeChecking.o \ 103 | 104 | 105 | % : $(OUT_DIR)/% 106 | 107 | 108 | TEST_XBB_EXE = testXbb 109 | $(OUT_DIR)/$(TEST_XBB_EXE) : $(OBJS) 110 | $(dir_guard) 111 | $(LD) -o $@ $(LDFLAGS) $^ 112 | 113 | 114 | all: $(TEST_XBB_EXE) 115 | 116 | 117 | clean: 118 | $(RM) -r objs bin 119 | 120 | 121 | -include $(AUTO_DEPS) 122 | 123 | 124 | .DEFAULT_GOAL=all 125 | -------------------------------------------------------------------------------- /unittest/PartialPrecomputedSxSHxRxT.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include "ref/Matrix4x4.h" 35 | #include "ScopedTimer.h" 36 | #include "TestValues.h" 37 | #include "TransformsAreClose.h" 38 | 39 | 40 | using namespace xbb; 41 | 42 | 43 | static const char * sPartialPrecomputedSxSHxRxTName = "Partial Precomputed S*SH*R*T"; 44 | TEST_CASE(sPartialPrecomputedSxSHxRxTName, "") 45 | { 46 | // time composing S*SH*R*T with precomputed S,SH,R,T using reference vs XBB 47 | volatile TestValues tv = TestValues::get(); 48 | 49 | const int repeatCount = 10000000; 50 | 51 | // Compose a transform using traditional OO approach 52 | double refTime = 0.0; 53 | { 54 | ScopedTimer timer(refTime); 55 | for (int rep=0; rep < repeatCount; ++rep) { 56 | XBB_INLINE_BLOCK 57 | { 58 | ref::Matrix4x4 S; 59 | S.makeScale(tv.scaleX, tv.scaleY, tv.scaleZ); 60 | 61 | ref::Matrix4x4 SH; 62 | SH.makeShear3(tv.shearX, tv.shearY, tv.shearZ); 63 | 64 | // Keeping around a ref::Matrix4x4 takes 128 bytes, so caching 65 | // Rx, Ry, and Rz would take 384 bytes and is most likely memory 66 | // prohibitive. 67 | ref::Matrix4x4 Rx; 68 | Rx.makeRotationX(tv.rotX); 69 | 70 | ref::Matrix4x4 Ry; 71 | Ry.makeRotationY(tv.rotY); 72 | 73 | ref::Matrix4x4 Rz; 74 | Rz.makeRotationZ(tv.rotZ); 75 | 76 | ref::Matrix4x4 T; 77 | T.makeTranslation(tv.translateX, tv.translateY, tv.translateZ); 78 | 79 | *gRefFinalTransform = S*SH*Rz*Ry*Rx*T; 80 | } 81 | } 82 | } 83 | 84 | // Compose a transform using XBB 85 | double xbbTime = 0.0; 86 | { 87 | 88 | // Keeping around a xbb::RotationX takes only 16 bytes, so caching 89 | // Rx, Ry, and Rz would only take 48 bytes and avoids 6 calls to 90 | // sin and cos and if possible caching will be worth the memory vs. 91 | // performance tradeoff 92 | REQUIRE(sizeof(xbb::RotationX) == 16); 93 | REQUIRE(sizeof(xbb::RotationY) == 16); 94 | REQUIRE(sizeof(xbb::RotationZ) == 16); 95 | xbb::RotationX Rx(tv.rotX); 96 | xbb::RotationY Ry(tv.rotY); 97 | xbb::RotationZ Rz(tv.rotZ); 98 | 99 | ScopedTimer timer(xbbTime); 100 | 101 | for (int rep=0; rep < repeatCount; ++rep) { 102 | XBB_INLINE_BLOCK 103 | { 104 | xbb::Scale S(tv.scaleX, tv.scaleY, tv.scaleZ); 105 | xbb::Shear3 SH(tv.shearX, tv.shearY, tv.shearZ); 106 | xbb::Translation T(tv.translateX, tv.translateY, tv.translateZ); 107 | 108 | (S*SH*Rz*Ry*Rx*T).to(*gXbbFinalTransform); 109 | } 110 | } 111 | } 112 | 113 | 114 | std::cout << sPartialPrecomputedSxSHxRxTName << ":"<< std::endl; 115 | //std::cout << "Ref Transform " << *gRefFinalTransform << std::endl; 116 | //std::cout << "xbb Transform " << gXbbFinalTransform << std::endl; 117 | TRANSFORMS_ARE_CLOSE(*gXbbFinalTransform, *gRefFinalTransform); 118 | 119 | std::cout << " ref Time " << refTime << std::endl; 120 | std::cout << " xbb Time " << xbbTime << std::endl; 121 | std::cout << " speedup " << refTime/xbbTime << "x" << std::endl << std::endl; 122 | } 123 | 124 | 125 | -------------------------------------------------------------------------------- /unittest/PrecomputedSxSHxRxT.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include "ref/Matrix4x4.h" 35 | #include "ScopedTimer.h" 36 | #include "TestValues.h" 37 | #include "TransformsAreClose.h" 38 | 39 | 40 | using namespace xbb; 41 | 42 | namespace { 43 | 44 | 45 | ref::Matrix4x4 gS; 46 | ref::Matrix4x4 gSH; 47 | ref::Matrix4x4 gRx; 48 | ref::Matrix4x4 gRy; 49 | ref::Matrix4x4 gRz; 50 | ref::Matrix4x4 gT; 51 | 52 | ref::Matrix4x4 * __attribute__((noinline)) getS() { 53 | return &gS; 54 | } 55 | ref::Matrix4x4 * __attribute__((noinline)) getSH() { 56 | return &gSH; 57 | } 58 | ref::Matrix4x4 * __attribute__((noinline)) getRx() { 59 | return &gRx; 60 | } 61 | ref::Matrix4x4 * __attribute__((noinline)) getRy() { 62 | return &gRy; 63 | } 64 | ref::Matrix4x4 * __attribute__((noinline)) getRz() { 65 | return &gRz; 66 | } 67 | ref::Matrix4x4 * __attribute__((noinline)) getT() { 68 | return &gT; 69 | } 70 | 71 | bool initRefTransforms() { 72 | 73 | volatile TestValues tv = TestValues::get(); 74 | 75 | gS.makeScale(tv.scaleX, tv.scaleY, tv.scaleZ); 76 | gSH.makeShear3(tv.shearX, tv.shearY, tv.shearZ); 77 | gRx.makeRotationX(tv.rotX); 78 | gRy.makeRotationY(tv.rotY); 79 | gRz.makeRotationZ(tv.rotZ); 80 | gT.makeTranslation(tv.translateX, tv.translateY, tv.translateZ); 81 | return true; 82 | } 83 | 84 | static bool initRefTransformVar = initRefTransforms(); 85 | 86 | } 87 | 88 | static const char * sPrecomputedSxSHxRxTName = "Precomputed S*SH*R*T"; 89 | TEST_CASE(sPrecomputedSxSHxRxTName, "") 90 | { 91 | // time composing S*SH*R*T with precomputed S,SH,R,T using reference vs XBB 92 | volatile TestValues tv = TestValues::get(); 93 | 94 | const int repeatCount = 10000000; 95 | 96 | // Compose a transform using traditional OO approach 97 | // Precompute the individual components 98 | // and just time how long it takes to concatenate them 99 | double refTime = 0.0; 100 | { 101 | XBB_INLINE_BLOCK 102 | { 103 | // Go through pointers so compiler cannot guarantee the 104 | // values used in each loop are identical and will actually 105 | // pull values from the pointers and do the math each 106 | // iteration 107 | ref::Matrix4x4 *S = getS(); 108 | ref::Matrix4x4 *SH = getSH(); 109 | ref::Matrix4x4 *Rx = getRx(); 110 | ref::Matrix4x4 *Ry = getRy(); 111 | ref::Matrix4x4 *Rz = getRz(); 112 | ref::Matrix4x4 *T = getT(); 113 | 114 | ScopedTimer timer(refTime); 115 | 116 | for (int rep=0; rep < repeatCount; ++rep) { 117 | 118 | *gRefFinalTransform = (*S)*(*SH)*(*Rz)*(*Ry)*(*Rx)*(*T); 119 | 120 | } 121 | } 122 | } 123 | 124 | // Compose a transform using XBB 125 | double xbbTime = 0.0; 126 | { 127 | 128 | XBB_INLINE_BLOCK 129 | { 130 | ScopedTimer timer(xbbTime); 131 | for (int rep=0; rep < repeatCount; ++rep) { 132 | 133 | // Note here we are using cached rotation transforms 134 | // they already have done the cos and sine of the angles 135 | // but rather than 128 bytes each, they are only 16 bytes 136 | // small enough to keep around with along side the angles 137 | xbb::RotationX Rx(tv.rX.cosineOfAngle, tv.rX.sineOfAngle); 138 | xbb::RotationY Ry(tv.rY.cosineOfAngle, tv.rY.sineOfAngle); 139 | xbb::RotationZ Rz(tv.rZ.cosineOfAngle, tv.rZ.sineOfAngle); 140 | 141 | // No value in caching the rest because it take no additional 142 | // space or overhead. 143 | // Ok, there is a little overhead in getting the 144 | xbb::Scale S(tv.scaleX, tv.scaleY, tv.scaleZ); 145 | xbb::Shear3 SH(tv.shearX, tv.shearY, tv.shearZ); 146 | xbb::Translation T(tv.translateX, tv.translateY, tv.translateZ); 147 | 148 | (S*SH*Rz*Ry*Rx*T).to(*gXbbFinalTransform); 149 | 150 | } 151 | } 152 | } 153 | 154 | std::cout << sPrecomputedSxSHxRxTName << ":"<< std::endl; 155 | //std::cout << "Ref Transform " << *gRefFinalTransform << std::endl; 156 | //std::cout << "xbb Transform " << *gXbbFinalTransform << std::endl; 157 | TRANSFORMS_ARE_CLOSE(*gXbbFinalTransform, *gRefFinalTransform); 158 | 159 | std::cout << " ref Time " << refTime << std::endl; 160 | std::cout << " xbb Time " << xbbTime << std::endl; 161 | std::cout << " speedup " << refTime/xbbTime << "x" << std::endl << std::endl; 162 | } 163 | 164 | 165 | -------------------------------------------------------------------------------- /unittest/ScopedTimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef XBB_UNITTEST_SCOPED_TIMER_H 29 | #define XBB_UNITTEST_SCOPED_TIMER_H 30 | 31 | #include 32 | 33 | struct ScopedTimer 34 | { 35 | private: 36 | double & mElapsedSeconds; 37 | std::chrono::time_point mStart; 38 | public: 39 | ScopedTimer(double & iElapsedSeconds) 40 | : mElapsedSeconds(iElapsedSeconds) 41 | , mStart(std::chrono::system_clock::now()) 42 | { 43 | } 44 | 45 | ~ScopedTimer() { 46 | std::chrono::time_point end = std::chrono::system_clock::now(); 47 | std::chrono::duration elapsedSeconds = end-mStart; 48 | mElapsedSeconds = elapsedSeconds.count(); 49 | } 50 | }; 51 | 52 | 53 | #endif // XBB_UNITTEST_SCOPED_TIMER_H 54 | 55 | -------------------------------------------------------------------------------- /unittest/StandardSxSHxRxT.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include "ref/Matrix4x4.h" 35 | #include "ScopedTimer.h" 36 | #include "TestValues.h" 37 | #include "TransformsAreClose.h" 38 | 39 | 40 | using namespace xbb; 41 | 42 | 43 | static const char * sStandardSxSHxRxTBestCaseName = "Standard S*SH*R*T (best case)"; 44 | TEST_CASE(sStandardSxSHxRxTBestCaseName, "") 45 | { 46 | // time composing S*SH*R*T with reference vs XBB 47 | volatile TestValues tv = TestValues::get(); 48 | 49 | const int repeatCount = 10000000; 50 | 51 | // Compose a transform using traditional OO approach 52 | double refTime = 0.0; 53 | { 54 | ScopedTimer timer(refTime); 55 | for (int rep=0; rep < repeatCount; ++rep) { 56 | XBB_INLINE_BLOCK 57 | { 58 | ref::Matrix4x4 S; 59 | S.makeScale(tv.scaleX, tv.scaleY, tv.scaleZ); 60 | 61 | ref::Matrix4x4 SH; 62 | SH.makeShear3(tv.shearX, tv.shearY, tv.shearZ); 63 | 64 | ref::Matrix4x4 Rx; 65 | Rx.makeRotationX(tv.rotX); 66 | 67 | ref::Matrix4x4 Ry; 68 | Ry.makeRotationY(tv.rotY); 69 | 70 | ref::Matrix4x4 Rz; 71 | Rz.makeRotationZ(tv.rotZ); 72 | 73 | ref::Matrix4x4 T; 74 | T.makeTranslation(tv.translateX, tv.translateY, tv.translateZ); 75 | 76 | // NOTE: if fully inlined, a compiler could do a pretty decent job 77 | // taking advantage of compile time constants from the "make???" routines. 78 | // Allowing the results to be on par with the XBB version. 79 | *gRefFinalTransform = S*SH*Rz*Ry*Rx*T; 80 | } 81 | } 82 | } 83 | 84 | // Compose a transform using XBB 85 | double xbbTime = 0.0; 86 | { 87 | ScopedTimer timer(xbbTime); 88 | for (int rep=0; rep < repeatCount; ++rep) { 89 | 90 | XBB_INLINE_BLOCK 91 | { 92 | xbb::Scale S(tv.scaleX, tv.scaleY, tv.scaleZ); 93 | xbb::Shear3 SH(tv.shearX, tv.shearY, tv.shearZ); 94 | xbb::RotationX Rx(tv.rotX); 95 | xbb::RotationY Ry(tv.rotY); 96 | xbb::RotationZ Rz(tv.rotZ); 97 | xbb::Translation T(tv.translateX, tv.translateY, tv.translateZ); 98 | 99 | (S*SH*Rz*Ry*Rx*T).to(*gXbbFinalTransform); 100 | } 101 | } 102 | } 103 | 104 | 105 | std::cout << sStandardSxSHxRxTBestCaseName << ":"<< std::endl; 106 | //std::cout << "Ref Transform " << *gRefFinalTransform << std::endl; 107 | //std::cout << "xbb Transform " << *gXbbFinalTransform << std::endl; 108 | TRANSFORMS_ARE_CLOSE(*gXbbFinalTransform, *gRefFinalTransform); 109 | 110 | std::cout << " ref Time " << refTime << std::endl; 111 | std::cout << " xbb Time " << xbbTime << std::endl; 112 | std::cout << " speedup " << refTime/xbbTime << "x" << std::endl << std::endl; 113 | } 114 | 115 | 116 | namespace { 117 | 118 | __attribute__((noinline)) void multiplySxSHxRzxRyxRxxT( 119 | ref::Matrix4x4 & result, 120 | const ref::Matrix4x4 & S, 121 | const ref::Matrix4x4 & SH, 122 | const ref::Matrix4x4 & Rz, 123 | const ref::Matrix4x4 & Ry, 124 | const ref::Matrix4x4 & Rx, 125 | const ref::Matrix4x4 & T); 126 | 127 | __attribute__((noinline)) void multiplySxSHxRzxRyxRxxT( 128 | xbb::Matrix4x3 & result, 129 | const xbb::Scale & S, 130 | const xbb::Shear3 & SH, 131 | const xbb::RotationZ & Rz, 132 | const xbb::RotationY & Ry, 133 | const xbb::RotationX & Rx, 134 | const xbb::Translation & T); 135 | 136 | void multiplySxSHxRzxRyxRxxT( 137 | ref::Matrix4x4 & result, 138 | const ref::Matrix4x4 & S, 139 | const ref::Matrix4x4 & SH, 140 | const ref::Matrix4x4 & Rz, 141 | const ref::Matrix4x4 & Ry, 142 | const ref::Matrix4x4 & Rx, 143 | const ref::Matrix4x4 & T) 144 | { 145 | XBB_INLINE_BLOCK 146 | { 147 | result = S*SH*Rz*Ry*Rx*T; 148 | } 149 | } 150 | 151 | 152 | void multiplySxSHxRzxRyxRxxT( 153 | xbb::Matrix4x3 & result, 154 | const xbb::Scale & S, 155 | const xbb::Shear3 & SH, 156 | const xbb::RotationZ & Rz, 157 | const xbb::RotationY & Ry, 158 | const xbb::RotationX & Rx, 159 | const xbb::Translation & T) 160 | { 161 | XBB_INLINE_BLOCK 162 | { 163 | (S*SH*Rz*Ry*Rx*T).to(result); 164 | } 165 | } 166 | 167 | } 168 | 169 | 170 | static const char * sStandardSxSHxRxTWorstCaseName = "Standard S*SH*R*T (worst case)"; 171 | TEST_CASE(sStandardSxSHxRxTWorstCaseName, "") 172 | { 173 | // time composing S*SH*R*T with reference vs XBB 174 | volatile TestValues tv = TestValues::get(); 175 | 176 | const int repeatCount = 10000000; 177 | 178 | // Compose a transform using traditional OO approach 179 | double refTime = 0.0; 180 | { 181 | ScopedTimer timer(refTime); 182 | for (int rep=0; rep < repeatCount; ++rep) { 183 | XBB_INLINE_BLOCK 184 | { 185 | ref::Matrix4x4 S; 186 | S.makeScale(tv.scaleX, tv.scaleY, tv.scaleZ); 187 | 188 | ref::Matrix4x4 SH; 189 | SH.makeShear3(tv.shearX, tv.shearY, tv.shearZ); 190 | 191 | ref::Matrix4x4 Rx; 192 | Rx.makeRotationX(tv.rotX); 193 | 194 | ref::Matrix4x4 Ry; 195 | Ry.makeRotationY(tv.rotY); 196 | 197 | ref::Matrix4x4 Rz; 198 | Rz.makeRotationZ(tv.rotZ); 199 | 200 | ref::Matrix4x4 T; 201 | T.makeTranslation(tv.translateX, tv.translateY, tv.translateZ); 202 | 203 | // NOTE: what we found in practice is 4x4 matrices being passed to functions 204 | // where the optimizer doesn't know the 0's or 1's. 205 | // So this represents a worst case scenario. 206 | multiplySxSHxRzxRyxRxxT(*gRefFinalTransform, S, SH, Rz, Ry, Rx, T); 207 | } 208 | } 209 | } 210 | 211 | // Compose a transform using XBB 212 | double xbbTime = 0.0; 213 | { 214 | ScopedTimer timer(xbbTime); 215 | for (int rep=0; rep < repeatCount; ++rep) { 216 | 217 | XBB_INLINE_BLOCK 218 | { 219 | xbb::Scale S(tv.scaleX, tv.scaleY, tv.scaleZ); 220 | xbb::Shear3 SH(tv.shearX, tv.shearY, tv.shearZ); 221 | xbb::RotationX Rx(tv.rotX); 222 | xbb::RotationY Ry(tv.rotY); 223 | xbb::RotationZ Rz(tv.rotZ); 224 | xbb::Translation T(tv.translateX, tv.translateY, tv.translateZ); 225 | 226 | multiplySxSHxRzxRyxRxxT(*gXbbFinalTransform, S, SH, Rz, Ry, Rx, T); 227 | } 228 | } 229 | } 230 | 231 | 232 | std::cout << sStandardSxSHxRxTWorstCaseName << ":"<< std::endl; 233 | //std::cout << "Ref Transform " << *gRefFinalTransform << std::endl; 234 | //std::cout << "xbb Transform " << *gXbbFinalTransform << std::endl; 235 | TRANSFORMS_ARE_CLOSE(*gXbbFinalTransform, *gRefFinalTransform); 236 | 237 | std::cout << " ref Time " << refTime << std::endl; 238 | std::cout << " xbb Time " << xbbTime << std::endl; 239 | std::cout << " speedup " << refTime/xbbTime << "x" << std::endl << std::endl; 240 | } 241 | 242 | 243 | -------------------------------------------------------------------------------- /unittest/TestValues.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "TestValues.h" 29 | 30 | namespace { 31 | 32 | ref::Matrix4x4 refFinalTransform; 33 | xbb::Matrix4x3 xbbFinalTransform; 34 | 35 | TestValues populateTestValues() 36 | { 37 | TestValues tv; 38 | 39 | 40 | tv.scaleX = 2.0; 41 | tv.scaleY = 3.0; 42 | tv.scaleZ = 4.0; 43 | tv.shearX = 0.1; 44 | tv.shearY = 0.2; 45 | tv.shearZ = 0.3; 46 | tv.translateX = 100; 47 | tv.translateY = 200; 48 | tv.translateZ = 300; 49 | tv.rotX = 1.39; 50 | tv.rotY = 2.45; 51 | tv.rotZ = 3.0; 52 | tv.rX.set(tv.rotX); 53 | tv.rY.set(tv.rotY); 54 | tv.rZ.set(tv.rotZ); 55 | 56 | tv.parentScaleX = 10; 57 | tv.parentScaleY = 20; 58 | tv.parentScaleZ = 30; 59 | tv.parentShearX = 0.4; 60 | tv.parentShearY = 0.5; 61 | tv.parentShearZ = 0.6; 62 | 63 | // Setup the parent matrix to be the inverse of a local matrix built 64 | // from the other tv values 65 | ref::Matrix4x4 S; 66 | S.makeScale(-tv.scaleX, -tv.scaleY, -tv.scaleZ); 67 | 68 | ref::Matrix4x4 SH; 69 | SH.makeShear3(tv.shearX, tv.shearY, tv.shearZ); 70 | 71 | ref::Matrix4x4 Rx; 72 | Rx.makeRotationX(-tv.rotX); 73 | 74 | ref::Matrix4x4 Ry; 75 | Ry.makeRotationY(-tv.rotY); 76 | 77 | ref::Matrix4x4 Rz; 78 | Rz.makeRotationZ(-tv.rotZ); 79 | 80 | ref::Matrix4x4 T; 81 | T.makeTranslation(-tv.translateX, -tv.translateY, -tv.translateZ); 82 | 83 | tv.parentWorld = S*SH.inverse()*Rz*Ry*Rx*T; 84 | 85 | return tv; 86 | } 87 | 88 | } 89 | 90 | const TestValues & TestValues::get() 91 | { 92 | static TestValues tv = populateTestValues(); 93 | return tv; 94 | } 95 | 96 | 97 | ref::Matrix4x4 *gRefFinalTransform = &refFinalTransform; 98 | xbb::Matrix4x3 *gXbbFinalTransform = &xbbFinalTransform; 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /unittest/TestValues.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef TEST_VALUES_H 29 | #define TEST_VALUES_H 30 | 31 | #include 32 | #include "ref/Matrix4x4.h" 33 | 34 | // To avoid optimizations where the compiler clones the function and uses 35 | // compile time know values that we put in the unit test, we will use 36 | // test values that are populated in a different compilation unit. 37 | // In a production program one wouldn't care, but usually in production the 38 | // values are not known at compile time and we don't want an unfair advantage 39 | struct TestValues 40 | { 41 | static __attribute__((noinline)) const TestValues & get(); 42 | 43 | 44 | double scaleX, scaleY, scaleZ; 45 | double shearX, shearY, shearZ; 46 | double translateX, translateY, translateZ; 47 | double rotX, rotY, rotZ; 48 | xbb::RotationX rX; 49 | xbb::RotationY rY; 50 | xbb::RotationZ rZ; 51 | 52 | double parentScaleX, parentScaleY, parentScaleZ; 53 | double parentShearX, parentShearY, parentShearZ; 54 | 55 | ref::Matrix4x4 parentWorld; 56 | }; 57 | 58 | // We can put computations in a loop but the compiler may skip them 59 | // unless the result appears to be used somehow. 60 | // So we place results in a global transform, then compiler can't assume that 61 | // another thread or something isn't using/watching that memory location. 62 | // This appears to be less overhead than calling a mock function 63 | extern ref::Matrix4x4 *gRefFinalTransform; 64 | extern xbb::Matrix4x3 *gXbbFinalTransform; 65 | 66 | 67 | #endif // TEST_VALUES_H 68 | 69 | -------------------------------------------------------------------------------- /unittest/TransformsAreClose.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef TRANSFORMS_ARE_CLOSE_H 29 | #define TRANSFORMS_ARE_CLOSE_H 1 30 | 31 | #include 32 | #include 33 | 34 | #include "FloatingPointComparisons.h" 35 | 36 | 37 | using namespace xbb; 38 | 39 | #define TRANSFORMS_ARE_CLOSE(LEFT, RIGHT) \ 40 | { \ 41 | auto left = LEFT; \ 42 | auto right = RIGHT; \ 43 | if (TransformsAreClose(left, right) == false) { \ 44 | std::cout << "Left Transform " << left << std::endl; \ 45 | std::cout << "Right Transform " << right << std::endl; \ 46 | REQUIRE(isClose(left.e00(), right.e00())); \ 47 | REQUIRE(isClose(left.e01(), right.e01())); \ 48 | REQUIRE(isClose(left.e02(), right.e02())); \ 49 | REQUIRE(isClose(left.e03(), right.e03())); \ 50 | \ 51 | REQUIRE(isClose(left.e10(), right.e10())); \ 52 | REQUIRE(isClose(left.e11(), right.e11())); \ 53 | REQUIRE(isClose(left.e12(), right.e12())); \ 54 | REQUIRE(isClose(left.e13(), right.e13())); \ 55 | \ 56 | REQUIRE(isClose(left.e20(), right.e20())); \ 57 | REQUIRE(isClose(left.e21(), right.e21())); \ 58 | REQUIRE(isClose(left.e22(), right.e22())); \ 59 | REQUIRE(isClose(left.e23(), right.e23())); \ 60 | \ 61 | REQUIRE(isClose(left.e30(), right.e30())); \ 62 | REQUIRE(isClose(left.e31(), right.e31())); \ 63 | REQUIRE(isClose(left.e32(), right.e32())); \ 64 | REQUIRE(isClose(left.e33(), right.e33())); \ 65 | } \ 66 | } 67 | 68 | template 69 | bool TransformsAreClose(const LeftT &iLeft, const RightT &iRight) 70 | { 71 | return (isClose(iRight.e00(), iLeft.e00())) && 72 | (isClose(iRight.e01(), iLeft.e01())) && 73 | (isClose(iRight.e02(), iLeft.e02())) && 74 | (isClose(iRight.e03(), iLeft.e03())) && 75 | 76 | (isClose(iRight.e10(), iLeft.e10())) && 77 | (isClose(iRight.e11(), iLeft.e11())) && 78 | (isClose(iRight.e12(), iLeft.e12())) && 79 | (isClose(iRight.e13(), iLeft.e13())) && 80 | 81 | (isClose(iRight.e20(), iLeft.e20())) && 82 | (isClose(iRight.e21(), iLeft.e21())) && 83 | (isClose(iRight.e22(), iLeft.e22())) && 84 | (isClose(iRight.e23(), iLeft.e23())) && 85 | 86 | (isClose(iRight.e30(), iLeft.e30())) && 87 | (isClose(iRight.e31(), iLeft.e31())) && 88 | (isClose(iRight.e32(), iLeft.e32())) && 89 | (isClose(iRight.e33(), iLeft.e33())); 90 | } 91 | 92 | #endif // TRANSFORMS_ARE_CLOSE_H 93 | 94 | -------------------------------------------------------------------------------- /unittest/TypeChecking.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | 35 | 36 | using namespace xbb; 37 | 38 | 39 | TEST_CASE("TypeChecking", "") 40 | { 41 | // exercise helper methods for comparing types, useful for templates to use 42 | // conditionals known at compile time vs template specialization 43 | 44 | xbb::Translation T; 45 | REQUIRE(T.isIdentity() == false) ; 46 | REQUIRE(T.is() == false) ; 47 | REQUIRE(T.is() == true); 48 | REQUIRE(T.is() == false); 49 | REQUIRE(T.is() == false); 50 | REQUIRE(T.is() == false); 51 | REQUIRE(T.is() == false); 52 | REQUIRE(T.is() == false); 53 | REQUIRE(T.is() == false); 54 | REQUIRE(T.is() == false); 55 | 56 | 57 | xbb::Identity I; 58 | REQUIRE(I.isIdentity() == true) ; 59 | REQUIRE(I.is() == true) ; 60 | REQUIRE(I.is() == false); 61 | REQUIRE(I.is() == false); 62 | REQUIRE(I.is() == false); 63 | REQUIRE(I.is() == false); 64 | REQUIRE(I.is() == false); 65 | REQUIRE(I.is() == false); 66 | REQUIRE(I.is() == false); 67 | REQUIRE(I.is() == false); 68 | 69 | xbb::Scale S; 70 | REQUIRE(S.isIdentity() == false) ; 71 | REQUIRE(S.is() == false) ; 72 | REQUIRE(S.is() == false); 73 | REQUIRE(S.is() == true); 74 | REQUIRE(S.is() == false); 75 | REQUIRE(S.is() == false); 76 | REQUIRE(S.is() == false); 77 | REQUIRE(S.is() == false); 78 | REQUIRE(S.is() == false); 79 | REQUIRE(S.is() == false); 80 | 81 | xbb::Shear3 SH; 82 | REQUIRE(SH.isIdentity() == false) ; 83 | REQUIRE(SH.is() == false) ; 84 | REQUIRE(SH.is() == false); 85 | REQUIRE(SH.is() == false); 86 | REQUIRE(SH.is() == true); 87 | REQUIRE(SH.is() == false); 88 | REQUIRE(SH.is() == false); 89 | REQUIRE(SH.is() == false); 90 | REQUIRE(SH.is() == false); 91 | REQUIRE(SH.is() == false); 92 | 93 | xbb::RotationX Rx; 94 | REQUIRE(Rx.isIdentity() == false) ; 95 | REQUIRE(Rx.is() == false) ; 96 | REQUIRE(Rx.is() == false); 97 | REQUIRE(Rx.is() == false); 98 | REQUIRE(Rx.is() == false); 99 | REQUIRE(Rx.is() == true); 100 | REQUIRE(Rx.is() == false); 101 | REQUIRE(Rx.is() == false); 102 | REQUIRE(Rx.is() == false); 103 | REQUIRE(Rx.is() == false); 104 | 105 | xbb::RotationY Ry; 106 | REQUIRE(Ry.isIdentity() == false) ; 107 | REQUIRE(Ry.is() == false) ; 108 | REQUIRE(Ry.is() == false); 109 | REQUIRE(Ry.is() == false); 110 | REQUIRE(Ry.is() == false); 111 | REQUIRE(Ry.is() == false); 112 | REQUIRE(Ry.is() == true); 113 | REQUIRE(Ry.is() == false); 114 | REQUIRE(Ry.is() == false); 115 | REQUIRE(Ry.is() == false); 116 | 117 | xbb::RotationZ Rz; 118 | REQUIRE(Rz.isIdentity() == false) ; 119 | REQUIRE(Rz.is() == false) ; 120 | REQUIRE(Rz.is() == false); 121 | REQUIRE(Rz.is() == false); 122 | REQUIRE(Rz.is() == false); 123 | REQUIRE(Rz.is() == false); 124 | REQUIRE(Rz.is() == false); 125 | REQUIRE(Rz.is() == true); 126 | REQUIRE(Rz.is() == false); 127 | REQUIRE(Rz.is() == false); 128 | 129 | xbb::Matrix3x3 mat3; 130 | REQUIRE(mat3.isIdentity() == false) ; 131 | REQUIRE(mat3.is() == false) ; 132 | REQUIRE(mat3.is() == false); 133 | REQUIRE(mat3.is() == false); 134 | REQUIRE(mat3.is() == false); 135 | REQUIRE(mat3.is() == false); 136 | REQUIRE(mat3.is() == false); 137 | REQUIRE(mat3.is() == false); 138 | REQUIRE(mat3.is() == true); 139 | REQUIRE(mat3.is() == false); 140 | 141 | xbb::Matrix4x3 mat4; 142 | REQUIRE(mat4.isIdentity() == false) ; 143 | REQUIRE(mat4.is() == false) ; 144 | REQUIRE(mat4.is() == false); 145 | REQUIRE(mat4.is() == false); 146 | REQUIRE(mat4.is() == false); 147 | REQUIRE(mat4.is() == false); 148 | REQUIRE(mat4.is() == false); 149 | REQUIRE(mat4.is() == false); 150 | REQUIRE(mat4.is() == false); 151 | REQUIRE(mat4.is() == true); 152 | } 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /unittest/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #define CATCH_CONFIG_RUNNER 32 | 33 | #include 34 | 35 | 36 | int main(int argc, char* const argv[]) 37 | { 38 | std::cout << std::fixed; 39 | 40 | int result = Catch::Session().run( argc, argv ); 41 | return result; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /unittest/ref/Vec3.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Intel Corporation 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef REF_VEC_3_H 29 | #define REF_VEC_3_H 30 | 31 | #include 32 | 33 | namespace ref { 34 | 35 | 36 | struct Vec3 37 | { 38 | Vec3() 39 | { 40 | // unitialized 41 | } 42 | 43 | Vec3(double iX, double iY, double iZ) 44 | : m {iX, iY, iZ} 45 | { 46 | } 47 | 48 | double x() const { return m[0]; } 49 | double y() const { return m[1]; } 50 | double z() const { return m[2]; } 51 | 52 | double m[3]; 53 | }; 54 | 55 | } // namespace ref 56 | 57 | #endif // REF_VEC_3_H 58 | --------------------------------------------------------------------------------