Allow scaling lines by a 2D vector ie: non-homogeneous scaling.
This commit is contained in:
parent
c70d2ad423
commit
f300c94924
2 changed files with 36 additions and 4 deletions
|
@ -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));
|
||||
|
|
34
src/line.inl
34
src/line.inl
|
@ -44,7 +44,17 @@ namespace cloonel {
|
|||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
template <typename T, uint32_t S>
|
||||
Line<T, S> operator+ ( const Vector<T, S>& parLhs, Line<T, S> parRhs ) {
|
||||
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>
|
||||
Line<T, S> operator+ (const Vector<T, S>& parLhs, Line<T, S> parRhs) {
|
||||
parRhs += parLhs;
|
||||
return parRhs;
|
||||
}
|
||||
|
@ -52,7 +62,7 @@ namespace cloonel {
|
|||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
template <typename T, uint32_t S>
|
||||
Line<T, S> operator- ( const Vector<T, S>& parLhs, Line<T, S> parRhs ) {
|
||||
Line<T, S> operator- (const Vector<T, S>& parLhs, Line<T, S> parRhs) {
|
||||
parRhs -= parLhs;
|
||||
return parRhs;
|
||||
}
|
||||
|
@ -60,7 +70,7 @@ namespace cloonel {
|
|||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
template <typename T, uint32_t S>
|
||||
Line<T, S> operator+ ( Line<T, S> parLhs, const Vector<T, S>& parRhs ) {
|
||||
Line<T, S> operator+ (Line<T, S> parLhs, const Vector<T, S>& parRhs) {
|
||||
parLhs += parRhs;
|
||||
return parLhs;
|
||||
}
|
||||
|
@ -68,11 +78,27 @@ namespace cloonel {
|
|||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
template <typename T, uint32_t S>
|
||||
Line<T, S> operator- ( Line<T, S> parLhs, const Vector<T, S>& parRhs ) {
|
||||
Line<T, S> operator- (Line<T, S> parLhs, const Vector<T, S>& parRhs) {
|
||||
parLhs -= parRhs;
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue