transformation_2d.h
Go to the documentation of this file.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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_2D_H
00051 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_TRANSFORMATION_2D_H
00052
00053 #include "prim_common.h"
00054 #include "point_2d.h"
00055 #include "xyz.h"
00056 #include "impl/prim_allocator.h"
00057 #include "../io/xml_o_stream.h"
00058 #include "../num/num_traits.h"
00059 #include "../util/shared_ptr.h"
00060 #include "../util/thread.h"
00061
00062 namespace lass
00063 {
00064 namespace prim
00065 {
00066 namespace impl
00067 {
00068 template <typename T, typename Cascade>
00069 class Transformation2DStorage: public util::ArrayStorage<T, Cascade>
00070 {
00071 public:
00072 Transformation2DStorage(): util::ArrayStorage<T, Cascade>() {}
00073 Transformation2DStorage(T* p): util::ArrayStorage<T, Cascade>(p) {}
00074 protected:
00075 void dispose()
00076 {
00077 impl::deallocateArray(this->pointer(), 9);
00078 }
00079 };
00080 }
00081
00082 template <typename T>
00083 class Transformation2D
00084 {
00085 public:
00086
00087 typedef Transformation2D<T> TSelf;
00088
00089 typedef typename util::CallTraits<T>::TValue TValue;
00090 typedef typename util::CallTraits<T>::TParam TParam;
00091 typedef typename util::CallTraits<T>::TReference TReference;
00092 typedef typename util::CallTraits<T>::TConstReference TConstReference;
00093 typedef num::NumTraits<T> TNumTraits;
00094 typedef size_t TSize;
00095
00096 enum { dimension = 3 };
00097
00098 template <typename U> struct Rebind
00099 {
00100 typedef Transformation2D<U> Type;
00101 };
00102
00103 Transformation2D();
00104 template <typename InputIterator> Transformation2D(InputIterator first, InputIterator last);
00105
00106 const Transformation2D<T> inverse() const;
00107
00108 const TValue* matrix() const;
00109 void swap(TSelf& other);
00110
00111 static const TSelf identity();
00112 static const TSelf translation(const Vector2D<T>& offset);
00113 static const TSelf scaler(const T& scale);
00114 static const TSelf scaler(const Vector2D<T>& scale);
00115 static const TSelf rotation(TParam radians);
00116
00117 private:
00118
00119 enum { matrixSize_ = 9 };
00120
00121 typedef util::SharedPtr<TValue, impl::Transformation2DStorage> TMatrix;
00122
00123 Transformation2D(const TMatrix& matrix, const TMatrix& inverseMatrix, bool dummy);
00124
00125 static const TMatrix& getIdentityMatrix();
00126
00127 TMatrix matrix_;
00128 mutable TMatrix inverseMatrix_;
00129
00130 static TMatrix identityMatrix_;
00131
00132 static util::Semaphore sync_;
00133 };
00134
00135 template <typename T> Transformation2D<T> concatenate(const Transformation2D<T>& first, const Transformation2D<T>& second);
00136
00137 template <typename T> Vector2D<T> transform(const Vector2D<T>& subject, const Transformation2D<T>& transformation);
00138 template <typename T> Point2D<T> transform(const Point2D<T>& subject, const Transformation2D<T>& transformation);
00139 template <typename T> Vector2D<T> normalTransform(const Vector2D<T>& subject, const Transformation2D<T>& transformation);
00140 template <typename T> std::pair<Vector2D<T>, T> normalTransform(const std::pair<Vector2D<T>, T>& subject, const Transformation2D<T>& transformation);
00141
00142 template<typename T, typename Char, typename Traits>
00143 std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& stream, const Transformation2D<T>& transformation);
00144
00145 template<typename T> io::XmlOStream& operator<<(io::XmlOStream& stream, const Transformation2D<T>& transformation);
00146
00147
00148
00149 template <typename T> util::Semaphore Transformation2D<T>::sync_;
00150
00151 }
00152
00153 }
00154
00155 #include "transformation_2d.inl"
00156
00157 #define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_TRANSFORMATION_2D
00158 #ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
00159 # include "pyobject_util.h"
00160 #endif
00161
00162 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_2D_H
00163 # include "aabb_2d_transformation_2d.h"
00164 #endif
00165
00166 #endif
00167
00168