return r.invert();
}
-
-template<typename T, unsigned N>
-inline LinAl::Vector<T, N+1> augment_vector(const LinAl::Vector<T, N> &v, T s)
-{
- LinAl::Vector<T, N+1> r;
- for(unsigned i=0; i<N; ++i)
- r[i] = v[i];
- r[N] = s;
- return r;
-}
-
-template<typename T, unsigned N>
-inline LinAl::Vector<T, N-1> reduce_vector(const LinAl::Vector<T, N> &v)
-{
- LinAl::Vector<T, N-1> r;
- for(unsigned i=0; i<N-1; ++i)
- r[i] = v[i];
- return r;
-}
-
-template<typename T, unsigned N>
-inline LinAl::Vector<T, N-1> divide_vector(const LinAl::Vector<T, N> &v)
-{
- LinAl::Vector<T, N-1> r;
- for(unsigned i=0; i<N-1; ++i)
- r[i] = v[i]/v[N-1];
- return r;
-}
-
-
template<typename T, unsigned D>
inline LinAl::Vector<T, D> AffineTransformation<T, D>::transform(const LinAl::Vector<T, D> &v) const
{
- return reduce_vector(matrix*augment_vector(v, T(1)));
+ return LinAl::Vector<T, D>(matrix*LinAl::Vector<T, D+1>(v, T(1)));
}
template<typename T, unsigned D>
inline LinAl::Vector<T, D> AffineTransformation<T, D>::transform_linear(const LinAl::Vector<T, D> &v) const
{
- return reduce_vector(matrix*augment_vector(v, T(0)));
+ return LinAl::Vector<T, D>(matrix*LinAl::Vector<T, D+1>(v, T(0)));
}
} // namespace Geometry
Vector(T, T, T, T);
template<typename U>
Vector(const Vector<U, N> &);
+ template<typename U>
+ Vector(const Vector<U, N-1> &, U);
+ template<typename U>
+ explicit Vector(const Vector<U, N+1> &);
Vector &operator*=(T);
Vector &operator/=(T);
(*this)[i] = v[i];
}
+template<typename T, unsigned N>
+template<typename U>
+inline Vector<T, N>::Vector(const Vector<U, N-1> &v, U s)
+{
+ for(unsigned i=0; i<N-1; ++i)
+ (*this)[i] = v[i];
+ (*this)[N-1] = s;
+}
+
+template<typename T, unsigned N>
+template<typename U>
+inline Vector<T, N>::Vector(const Vector<U, N+1> &v)
+{
+ for(unsigned i=0; i<N; ++i)
+ (*this)[i] = v[i];
+}
+
template<typename T, unsigned N>
inline Vector<T, N> &Vector<T, N>::operator*=(T s)
{