Added [Cube|Rect]::ExtendTo(X, Y[, Z]);
Former-commit-id: 6f3a92644acd818f94088347cc6f1be939adb7f9
This commit is contained in:
parent
8fff32e145
commit
49cdbc3c47
|
|
@ -29,6 +29,7 @@ class NzCube
|
|||
bool Contains(const NzVector3<T>& point) const;
|
||||
bool Contains(const NzCube& cube) const;
|
||||
|
||||
NzCube& ExtendTo(T X, T Y, T Z);
|
||||
NzCube& ExtendTo(const NzVector3<T>& point);
|
||||
NzCube& ExtendTo(const NzCube& cube);
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ class NzCube
|
|||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzCube<T>& vec);
|
||||
std::ostream& operator<<(std::ostream& out, const NzCube<T>& cube);
|
||||
|
||||
typedef NzCube<double> NzCubed;
|
||||
typedef NzCube<float> NzCubef;
|
||||
|
|
|
|||
|
|
@ -63,15 +63,15 @@ bool NzCube<T>::Contains(const NzCube<T>& cube) const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
||||
NzCube<T>& NzCube<T>::ExtendTo(T X, T Y, T Z)
|
||||
{
|
||||
width = std::max(x + width, point.x);
|
||||
height = std::max(y + height, point.y);
|
||||
depth = std::max(z + depth, point.z);
|
||||
width = std::max(x + width, X);
|
||||
height = std::max(y + height, Y);
|
||||
depth = std::max(z + depth, Z);
|
||||
|
||||
x = std::min(x, point.x);
|
||||
y = std::min(y, point.y);
|
||||
z = std::min(z, point.z);
|
||||
x = std::min(x, X);
|
||||
y = std::min(y, Y);
|
||||
z = std::min(z, Z);
|
||||
|
||||
width -= x;
|
||||
height -= y;
|
||||
|
|
@ -80,6 +80,12 @@ NzCube<T>& NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzVector3<T>& point)
|
||||
{
|
||||
return ExtendTo(point.x, point.y, point.z);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzCube<T>& NzCube<T>::ExtendTo(const NzCube& cube)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class NzRect
|
|||
bool Contains(const NzVector2<T>& point) const;
|
||||
bool Contains(const NzRect& rect) const;
|
||||
|
||||
NzRect& ExtendTo(T X, T Y);
|
||||
NzRect& ExtendTo(const NzVector2<T>& point);
|
||||
NzRect& ExtendTo(const NzRect& rect);
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ class NzRect
|
|||
};
|
||||
|
||||
template<typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const NzRect<T>& vec);
|
||||
std::ostream& operator<<(std::ostream& out, const NzRect<T>& rect);
|
||||
|
||||
typedef NzRect<double> NzRectd;
|
||||
typedef NzRect<float> NzRectf;
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ bool NzRect<T>::Contains(const NzRect<T>& rect) const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::ExtendTo(const NzVector2<T>& point)
|
||||
NzRect<T>& NzRect<T>::ExtendTo(T X, T Y)
|
||||
{
|
||||
width = std::max(x + width, point.x);
|
||||
height = std::max(y + height, point.y);
|
||||
width = std::max(x + width, X);
|
||||
height = std::max(y + height, Y);
|
||||
|
||||
x = std::min(x, point.x);
|
||||
y = std::min(y, point.y);
|
||||
x = std::min(x, X);
|
||||
y = std::min(y, Y);
|
||||
|
||||
width -= x;
|
||||
height -= y;
|
||||
|
|
@ -70,6 +70,12 @@ NzRect<T>& NzRect<T>::ExtendTo(const NzVector2<T>& point)
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::ExtendTo(const NzVector2<T>& point)
|
||||
{
|
||||
return ExtendTo(point.x, point.y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzRect<T>& NzRect<T>::ExtendTo(const NzRect& rect)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue