195 lines
6.2 KiB
C++
195 lines
6.2 KiB
C++
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// NoesisGUI - http://www.noesisengine.com
|
|
// Copyright (c) 2013 Noesis Technologies S.L. All Rights Reserved.
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#include <NsCore/Math.h>
|
|
|
|
|
|
namespace Noesis
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point::Point(): Vector2(0.0f, 0.0f)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point::Point(float x, float y): Vector2(x, y)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point::Point(const Pointi& point): Vector2((float)point.x, (float)point.y)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point::Point(const Vector2& v): Vector2(v)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point::Point(const Size& size): Vector2(size.width, size.height)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Pointi::Pointi(): x(0), y(0)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Pointi::Pointi(int xx, int yy): x(xx), y(yy)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Pointi::Pointi(const Point& p): x(Round(p.x)), y(Round(p.y))
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Pointi::Pointi(const Sizei& size) : x(size.width), y(size.height)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point3D::Point3D(): x(0.0f), y(0.0f), z(0.0f)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point3D::Point3D(float xx, float yy, float zz): x(xx), y(yy), z(zz)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point3D::Point3D(const Point& p): x(p.x), y(p.y), z(0.0f)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point3D& Point3D::operator=(const Point& point)
|
|
{
|
|
x = point.x;
|
|
y = point.y;
|
|
z = 0.0f;
|
|
return *this;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline bool Point3D::operator==(const Point3D& p) const
|
|
{
|
|
return x == p.x && y == p.y && z == p.z;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline bool Point3D::operator!=(const Point3D& p) const
|
|
{
|
|
return !(*this == p);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point3D operator+(const Point3D& p0, const Point3D& p1)
|
|
{
|
|
return Point3D(p0.x + p1.x, p0.y + p1.y, p0.z + p1.z);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point3D operator-(const Point3D& p0, const Point3D& p1)
|
|
{
|
|
return Point3D(p0.x - p1.x, p0.y - p1.y, p0.z - p1.z);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point3D operator*(const Point3D& p, float v)
|
|
{
|
|
return Point3D(p.x * v, p.y * v, p.z * v);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point3D operator*(float v, const Point3D& p)
|
|
{
|
|
return Point3D(p.x * v, p.y * v, p.z * v);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point4D::Point4D(): x(0.0f), y(0.0f), z(0.0f), w(0.0f)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point4D::Point4D(float xx, float yy, float zz, float ww): x(xx), y(yy), z(zz), w(ww)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point4D::Point4D(const Point& p): x(p.x), y(p.y), z(0.0f), w(0.0f)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point4D::Point4D(const Point3D& p): x(p.x), y(p.y), z(p.z), w(0.0f)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point4D& Point4D::operator=(const Point& p)
|
|
{
|
|
x = p.x;
|
|
y = p.y;
|
|
z = 0.0f;
|
|
w = 0.0f;
|
|
return *this;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline Point4D& Point4D::operator=(const Point3D& p)
|
|
{
|
|
x = p.x;
|
|
y = p.y;
|
|
z = p.z;
|
|
w = 0.0f;
|
|
return *this;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline bool Point4D::operator==(const Point4D& p) const
|
|
{
|
|
return x == p.x && y == p.y && z == p.z && w == p.w;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline bool Point4D::operator!=(const Point4D& p) const
|
|
{
|
|
return !(*this == p);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point4D operator+(const Point4D& p0, const Point4D& p1)
|
|
{
|
|
return Point4D(p0.x + p1.x, p0.y + p1.y, p0.z + p1.z, p0.w + p1.w);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point4D operator-(const Point4D& p0, const Point4D& p1)
|
|
{
|
|
return Point4D(p0.x - p1.x, p0.y - p1.y, p0.z - p1.z, p0.w - p1.w);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point4D operator*(const Point4D& p, float v)
|
|
{
|
|
return Point4D(p.x * v, p.y * v, p.z * v, p.w * v);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
inline const Point4D operator*(float v, const Point4D& p)
|
|
{
|
|
return Point4D(p.x * v, p.y * v, p.z * v, p.w * v);
|
|
}
|
|
|
|
}
|