Allow scaling lines by a 2D vector ie: non-homogeneous scaling.

This commit is contained in:
King_DuckZ 2014-08-19 21:48:41 +02:00
parent c70d2ad423
commit f300c94924
2 changed files with 36 additions and 4 deletions

View file

@ -44,6 +44,8 @@ namespace cloonel {
Line& operator+= ( const Point& parRhs ) __attribute__((flatten));
Line& operator-= ( const Point& parRhs ) __attribute__((flatten));
template <typename U>
Line& operator*= ( const Vector<U, S>& parRhs ) __attribute__((flatten));
private:
Vector<Point, 2> m_points;
@ -57,6 +59,10 @@ namespace cloonel {
Line<T, S> operator+ ( const Vector<T, S>& parLhs, Line<T, S> parRhs ) __attribute__((pure)) __attribute__((flatten));
template <typename T, uint32_t S>
Line<T, S> operator- ( const Vector<T, S>& parLhs, Line<T, S> parRhs ) __attribute__((pure)) __attribute__((flatten));
template <typename T, typename U, uint32_t S>
Line<T, S> operator* ( const Vector<U, S>& parLhs, Line<T, S> parRhs ) __attribute__((pure)) __attribute__((flatten));
template <typename T, typename U, uint32_t S>
Line<T, S> operator* ( Line<T, S> parLhs, const Vector<U, S>& parRhs ) __attribute__((pure)) __attribute__((flatten));
template <typename T>
bool operator> ( const Vector<T, 2>& parLhs, const Line<T, 2>& parRhs ) __attribute__((pure));

View file

@ -41,6 +41,16 @@ namespace cloonel {
return *this;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, uint32_t S>
template <typename U>
Line<T, S>& Line<T, S>::operator*= (const Vector<U, S>& parRhs) {
m_points.x() = static_cast<Point>(m_points.x() * parRhs);
m_points.y() = static_cast<Point>(m_points.y() * parRhs);
return *this;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, uint32_t S>
@ -73,6 +83,22 @@ namespace cloonel {
return parLhs;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, typename U, uint32_t S>
Line<T, S> operator* (const Vector<U, S>& parLhs, Line<T, S> parRhs) {
parRhs *= parLhs;
return parRhs;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, typename U, uint32_t S>
Line<T, S> operator* (Line<T, S> parLhs, const Vector<U, S>& parRhs) {
parLhs *= parRhs;
return parLhs;
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T>