Cortex  10.0.0-a4
VectorOps.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
43 
44 #ifndef IE_CORE_VECTOROPS_H
45 #define IE_CORE_VECTOROPS_H
46 
47 #include "IECore/VectorTraits.h"
48 
49 namespace IECore
50 {
51 
53 template<typename T>
54 inline void vecSet( T &v, unsigned int i, typename VectorTraits<T>::BaseType x );
55 
57 template<typename T>
58 inline void vecSetAll( T &v, typename VectorTraits<T>::BaseType x );
59 
61 template<typename T>
62 inline typename VectorTraits<T>::BaseType vecGet( const T &v, unsigned int i );
63 
65 template<typename T>
66 inline T vecAdd( const T &v1, const T &v2 );
67 
70 template<typename T>
71 inline void vecAdd( const T &v1, const T &v2, T &result );
72 
74 template<typename T>
75 inline T vecSub( const T &v1, const T &v2 );
76 
79 template<typename T>
80 inline void vecSub( const T &v1, const T &v2, T &result );
81 
83 template<typename T>
84 inline T vecMul( const T& v1, typename VectorTraits<T>::BaseType v2);
85 
88 template<typename T>
89 inline void vecMul( const T &v1, typename VectorTraits<T>::BaseType v2, T &result );
90 
92 template<typename T>
93 inline T vecMul( const T &v1, const T &v2 );
94 
97 template<typename T>
98 inline void vecMul( const T &v1, const T &v2, T &result);
99 
101 template<typename T>
102 inline T vecDiv( const T &v1, typename VectorTraits<T>::BaseType v2 );
103 
106 template<typename T>
107 inline void vecDiv( const T &v1, typename VectorTraits<T>::BaseType v2, T &result );
108 
110 template<typename T>
111 inline T vecDiv( const T &v1, const T &v2 );
112 
115 template<typename T>
116 inline void vecDiv( const T &v1, const T &v2, T &result );
117 
119 template<typename T>
120 inline typename VectorTraits<T>::BaseType vecDot( const T &v1, const T &v2 );
121 
123 template<typename T>
124 inline typename VectorTraits<T>::BaseType vecLength2( const T &v );
125 
127 template<typename T>
128 inline typename VectorTraits<T>::BaseType vecLength( const T &v );
129 
131 template<typename T>
132 inline void vecNormalize( T &v );
133 
135 template<typename T>
136 inline typename VectorTraits<T>::BaseType vecDistance2( const T &v1, const T &v2 );
137 
139 template<typename T>
140 inline typename VectorTraits<T>::BaseType vecDistance( const T &v1, const T &v2 );
141 
143 template<typename T, typename S>
144 inline S vecConvert( const T &v );
145 
147 template<typename T, typename S>
148 inline void vecConvert( const T &v1, S &v2 );
149 
152 template<typename T, typename S>
154 {
155  inline S operator()( const T &v ) const;
156 };
157 
160 template<typename T>
161 inline T vecConstruct( const typename VectorTraits<T>::BaseType *components );
162 
164 template<typename T>
165 inline T vecCross( const T &v1, const T &v2 );
166 
167 } // namespace IECore
168 
169 #include "IECore/VectorOps.inl"
170 
171 #endif // IE_CORE_VECTOROPS_H
VectorTraits< T >::BaseType vecLength(const T &v)
Returns the length of v.
T vecDiv(const T &v1, typename VectorTraits< T >::BaseType v2)
Division by a scalar returning a new vector.
T vecSub(const T &v1, const T &v2)
Subtracts v2 from v1, returning a new vector.
T vecConstruct(const typename VectorTraits< T >::BaseType *components)
S vecConvert(const T &v)
Converts from one vector type to another.
VectorTraits< T >::BaseType vecDot(const T &v1, const T &v2)
Returns the dot product of v1 and v2.
VectorTraits< T >::BaseType vecLength2(const T &v)
Returns the squared length of v.
VectorTraits< T >::BaseType vecGet(const T &v, unsigned int i)
Returns the value of the ith component of v.
Definition: VectorOps.h:153
T::BaseType BaseType
The type of the components of the vector.
Definition: VectorTraits.h:51
void vecNormalize(T &v)
Normalizes v in place. If the length of v is zero then has no effect.
T vecCross(const T &v1, const T &v2)
Returns the cross product of v1 and v2, which must be 3-dimensional vectors.
void vecSet(T &v, unsigned int i, typename VectorTraits< T >::BaseType x)
Sets the ith component of v to the value x.
VectorTraits< T >::BaseType vecDistance2(const T &v1, const T &v2)
Returns the distance squared between v1 and v2.
void vecSetAll(T &v, typename VectorTraits< T >::BaseType x)
Sets all components of v to the value x.
T vecAdd(const T &v1, const T &v2)
Adds v1 to v2 returning a new vector.
T vecMul(const T &v1, typename VectorTraits< T >::BaseType v2)
Perform multiplication of v1 by scalar value v2, returning a new vector.
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43
VectorTraits< T >::BaseType vecDistance(const T &v1, const T &v2)
Returns the distance between v1 and v2.