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

ShLibPoint.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 SHLIBPOINT_HPP
00028 #define SHLIBPOINT_HPP
00029 
00030 #include "ShPoint.hpp"
00031 #include "ShVector.hpp"
00032 #include "ShLib.hpp"
00033 
00034 namespace SH {
00035 SH_SHLIB_USUAL_OPERATIONS(ShPoint)
00036 SH_SHLIB_BINARY_RETTYPE_OPERATION(ShPoint, operator-, ShVector, N)
00037 SH_SHLIB_SPECIAL_RETTYPE_CONST_SCALAR_OP(ShPoint, operator-, ShVector, 1)
00038 
00039 SH_SHLIB_LEFT_MATRIX_OPERATION(ShPoint, operator|, M)
00040 
00041 // TODO: Special cases for homogeneous matrix multiplication etc.
00042 
00043 template<ShBindingType B1, ShBindingType B2, typename T, bool S1>
00044 ShPoint<3, SH_TEMP, T, false> operator|(const ShMatrix<4, 4, B1, T>& m,
00045                                         const ShPoint<3, B2, T, S1>& v)
00046 {
00047   ShPoint<4, SH_TEMP, T, false> t;
00048   t(0,1,2) = v;
00049   t(3) = ShAttrib<1, SH_CONST, T>(1.0f);
00050   ShPoint<4, SH_TEMP, T, false> r = m | t;
00051   return r(0,1,2)/r(3);
00052 }
00053 
00054 template<ShBindingType B1, ShBindingType B2, typename T, bool S1>
00055 ShPoint<2, SH_TEMP, T, false> operator|(const ShMatrix<3, 3, B1, T>& m,
00056                                         const ShPoint<2, B2, T, S1>& v)
00057 {
00058   ShPoint<3, SH_TEMP, T, false> t;
00059   t(0,1) = v;
00060   t(2) = ShAttrib<1, SH_CONST, T>(1.0f);
00061   ShPoint<3, SH_TEMP, T, false> r = m | t;
00062   return r(0,1)/r(2);
00063 }
00064 
00065 template<ShBindingType B1, ShBindingType B2, typename T, bool S1>
00066 ShPoint<1, SH_TEMP, T, false> operator|(const ShMatrix<2, 2, B1, T>& m,
00067                                         const ShPoint<1, B2, T, S1>& v)
00068 {
00069   ShPoint<2, SH_TEMP, T, false> t;
00070   t(0) = v;
00071   t(1) = ShAttrib<1, SH_CONST, T>(1.0f);
00072   ShPoint<2, SH_TEMP, T, false> r = m | t;
00073   return r(0)/r(1);
00074 }
00075 
00076 }
00077 
00078 #endif

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