Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShLibPosition.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory
00004 // Project administrator: Michael D. McCool
00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa,
00006 //          Michael D. McCool
00007 // 
00008 // This software is provided 'as-is', without any express or implied
00009 // warranty. In no event will the authors be held liable for any damages
00010 // arising from the use of this software.
00011 // 
00012 // Permission is granted to anyone to use this software for any purpose,
00013 // including commercial applications, and to alter it and redistribute it
00014 // freely, subject to the following restrictions:
00015 // 
00016 // 1. The origin of this software must not be misrepresented; you must
00017 // not claim that you wrote the original software. If you use this
00018 // software in a product, an acknowledgment in the product documentation
00019 // would be appreciated but is not required.
00020 // 
00021 // 2. Altered source versions must be plainly marked as such, and must
00022 // not be misrepresented as being the original software.
00023 // 
00024 // 3. This notice may not be removed or altered from any source
00025 // distribution.
00027 #ifndef SHLIBPOSITION_HPP
00028 #define SHLIBPOSITION_HPP
00029 
00030 #include "ShPosition.hpp"
00031 #include "ShVector.hpp"
00032 #include "ShPoint.hpp"
00033 #include "ShLib.hpp"
00034 
00035 namespace SH {
00036 
00037 SH_SHLIB_USUAL_OPERATIONS_RETTYPE(ShPosition, ShPoint);
00038 SH_SHLIB_BINARY_RETTYPE_OPERATION(ShPosition, operator-, ShVector, N);
00039 SH_SHLIB_SPECIAL_RETTYPE_CONST_SCALAR_OP(ShPosition, operator-, ShVector, 1);
00040 
00041 SH_SHLIB_LEFT_MATRIX_RETTYPE_OPERATION(ShPosition, operator|, ShPoint, M);
00042 
00043 // TODO: Special cases for homogeneous matrix multiplication etc.
00044 
00045 template<ShBindingType B1, ShBindingType B2, typename T, bool S1>
00046 ShPoint<3, SH_TEMP, T, false> operator|(const ShMatrix<4, 4, B1, T>& m,
00047                                         const ShPosition<3, B2, T, S1>& v)
00048 {
00049   ShPoint<4, SH_TEMP, T, false> t;
00050   t(0,1,2) = v;
00051   t(3) = ShAttrib<1, SH_CONST, T>(1.0f);
00052   ShPoint<4, SH_TEMP, T, false> r = m | t;
00053   return r(0,1,2)/r(3);
00054 }
00055 
00056 template<ShBindingType B1, ShBindingType B2, typename T, bool S1>
00057 ShPoint<2, SH_TEMP, T, false> operator|(const ShMatrix<3, 3, B1, T>& m,
00058                                         const ShPosition<2, B2, T, S1>& v)
00059 {
00060   ShPoint<3, SH_TEMP, T, false> t;
00061   t(0,1) = v;
00062   t(2) = ShAttrib<1, SH_CONST, T>(1.0f);
00063   ShPoint<3, SH_TEMP, T, false> r = m | t;
00064   return r(0,1)/r(2);
00065 }
00066 
00067 template<ShBindingType B1, ShBindingType B2, typename T, bool S1>
00068 ShPosition<1, SH_TEMP, T, false> operator|(const ShMatrix<2, 2, B1, T>& m,
00069                                            const ShPosition<1, B2, T, S1>& v)
00070 {
00071   ShPoint<2, SH_TEMP, T, false> t;
00072   t(0) = v;
00073   t(1) = ShAttrib<1, SH_CONST, T>(1.0f);
00074   ShPoint<2, SH_TEMP, T, false> r = m | t;
00075   return r(0)/r(1);
00076 }
00077 
00078 }
00079 
00080 
00081 #endif

Generated on Mon Jan 24 18:36:33 2005 for Sh by  doxygen 1.4.1