LibGfx: Add component wise * and / operators to Vector3 and Vector4

This commit is contained in:
Stephan Unverwerth 2021-05-11 19:24:39 +02:00 committed by Andreas Kling
parent b8fd52fad6
commit 077c340ea2
2 changed files with 20 additions and 0 deletions

View file

@ -54,6 +54,16 @@ public:
return Vector3(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z);
}
constexpr Vector3 operator*(const Vector3& other) const
{
return Vector3(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z);
}
constexpr Vector3 operator/(const Vector3& other) const
{
return Vector3(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z);
}
constexpr Vector3 operator*(T f) const
{
return Vector3(m_x * f, m_y * f, m_z * f);

View file

@ -59,6 +59,16 @@ public:
return Vector4(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z, m_w - other.m_w);
}
constexpr Vector4 operator*(const Vector4& other) const
{
return Vector4(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z, m_w * other.m_w);
}
constexpr Vector4 operator/(const Vector4& other) const
{
return Vector4(m_x / other.m_x, m_y / other.m_y, m_z / other.m_z, m_w / other.m_w);
}
constexpr Vector4 operator*(T f) const
{
return Vector4(m_x * f, m_y * f, m_z * f, m_w * f);