00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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