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

ShLibVector.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 SHLIBVECTOR_HPP 00028 #define SHLIBVECTOR_HPP 00029 00030 #include "ShVector.hpp" 00031 #include "ShLib.hpp" 00032 00033 namespace SH { 00034 00035 SH_SHLIB_USUAL_NON_UNIT_OPS_RETTYPE(ShVector, ShVector); 00036 00037 template<int N, ShBindingType B1, typename T, bool S1> 00038 ShVector<N, SH_TEMP, T, false> 00039 abs(const ShVector<N, B1, T, S1>& var) 00040 { 00041 ShGeneric<N, T> t = abs(static_cast< ShGeneric<N, T> >(var)); 00042 ShVector<N, SH_TEMP, T, false> vec(t.node(), t.swizzle(), t.neg()); 00043 return vec; 00044 } 00045 00046 template<int N, ShBindingType B1, typename T, bool S1> 00047 ShVector<N, SH_TEMP, T, false> 00048 normalize(const ShVector<N, B1, T, S1>& var) 00049 { 00050 ShGeneric<N, T> t = normalize(static_cast< ShGeneric<N, T> >(var)); 00051 ShVector<N, SH_TEMP, T, false> vec(t.node(), t.swizzle(), t.neg()); 00052 return vec; 00053 } 00054 00055 00056 00057 00058 SH_SHLIB_USUAL_SUBTRACT(ShVector); 00059 00060 SH_SHLIB_LEFT_MATRIX_OPERATION(ShVector, operator|, M); 00061 00062 template<int N, ShBindingType B1, ShBindingType B2, typename T, bool S1, bool S2> 00063 ShGeneric<1, T> operator|(const ShVector<N, B1, T, S1>& a, 00064 const ShVector<N, B2, T, S2>& b) 00065 { 00066 return dot(a, b); 00067 } 00068 00069 template<ShBindingType B1, ShBindingType B2, typename T, bool S1> 00070 ShVector<3, SH_TEMP, T, false> operator|(const ShMatrix<4, 4, B1, T>& m, 00071 const ShVector<3, B2, T, S1>& v) 00072 { 00073 ShVector<3, SH_TEMP, T, false> t; 00074 for (int i = 0; i < 3; i++) { 00075 t(i) = dot(m[i](0,1,2), v); 00076 } 00077 return t; 00078 } 00079 00080 template<ShBindingType B1, ShBindingType B2, typename T, bool S1> 00081 ShVector<2, SH_TEMP, T, false> operator|(const ShMatrix<3, 3, B1, T>& m, 00082 const ShVector<2, B2, T, S1>& v) 00083 { 00084 ShVector<2, SH_TEMP, T, false> t; 00085 for (int i = 0; i < 2; i++) { 00086 t(i) = dot(m[i](0,1), v); 00087 } 00088 return t; 00089 } 00090 00091 template<ShBindingType B1, ShBindingType B2, typename T, bool S1> 00092 ShVector<1, SH_TEMP, T, false> operator|(const ShMatrix<2, 2, B1, T>& m, 00093 const ShVector<1, B2, T, S1>& v) 00094 { 00095 ShVector<1, SH_TEMP, T, false> t; 00096 for (int i = 0; i < 1; i++) { 00097 t(i) = dot(m[i](0), v); 00098 } 00099 return t; 00100 } 00101 00102 } 00103 00104 #endif

Generated on Mon Oct 18 14:17:39 2004 for Sh by doxygen 1.3.7