Added [Cube/Rect]::Get[Negative/Positive]Vertex
Former-commit-id: 66e4851be7751402077ea67df0554a51f3d28df2
This commit is contained in:
@@ -91,12 +91,40 @@ NzVector2<T> NzRect<T>::GetCenter() const
|
||||
return NzVector2<T>(x + width/F(2.0), y + height/F(2.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetNegativeVertex(const NzVector2<T>& normal) const
|
||||
{
|
||||
NzVector2<T> neg(GetPosition());
|
||||
|
||||
if (normal.x < F(0.0))
|
||||
neg.x += width;
|
||||
|
||||
if (normal.y < F(0.0))
|
||||
neg.y += height;
|
||||
|
||||
return neg;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetPosition() const
|
||||
{
|
||||
return NzVector2<T>(x, y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetPositiveVertex(const NzVector2<T>& normal) const
|
||||
{
|
||||
NzVector2<T> pos(GetPosition());
|
||||
|
||||
if (normal.x > F(0.0))
|
||||
pos.x += width;
|
||||
|
||||
if (normal.y > F(0.0))
|
||||
pos.y += height;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetSize() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user