Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Riyadh International

Pages: [1]
1
General discussions / Vector's equality and inequality operators
« on: September 12, 2011, 08:43:44 am »
Hello everybody. Thanks for SFML loking forward to new release and more tutorials like Joystick.

Anyway I see this in Vector2.inl and Vector3.inl:
Code: [Select]

template <typename T>
bool operator ==(const Vector2<T>& V1, const Vector2<T>& V2)
{
    return (V1.x == V2.x) && (V1.y == V2.y);
}


template <typename T>
bool operator !=(const Vector2<T>& V1, const Vector2<T>& V2)
{
    return (V1.x != V2.x) || (V1.y != V2.y);
}

template <typename T>
bool operator ==(const Vector3<T>& V1, const Vector3<T>& V2)
{
    return (V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z);
}

template <typename T>
bool operator !=(const Vector3<T>& V1, const Vector3<T>& V2)
{
    return (V1.x != V2.x) || (V1.y != V2.y) || (V1.z != V2.z);
}


This will not work reliable for Floats but only Integers.
I found article which helped me and maybe you too:
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

Pages: [1]