# FR: Vector3D: Add operator==/!=

**URL:** <https://forum.juce.com/t/fr-vector3d-add-operator/68324>\
**Category:** Feature Requests\
**Created:** [February 26, 2026, 5:39pm UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324 "2026-02-26T17:39:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [February 26, 2026, 5:39pm UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/1 "2026-02-26T17:39:28Z")

</div>

See title - it’s a very simple FR!

---

<div class="post-metadata">

**Author:** ![kerfuffle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kerfuffle/32/11805_2.png) [@kerfuffle](https://forum.juce.com/u/kerfuffle)\
**Post date:** [February 26, 2026, 7:27pm UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/2 "2026-02-26T19:27:10Z")

</div>

Comparing floating point values to each other is potentially problematic, and so `==` and `!=` on a Vector3D will also be problematic. It would only be suitable for specific cases such as comparing to `(0, 0, 0)`.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [February 26, 2026, 7:51pm UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/3 "2026-02-26T19:51:03Z")

</div>

It’s a perfectly valid request in my experience. Besides, this is why JUCE provides `exactlyEqual` and `approximatelyEqual`. Treating floating points vals like some untouchable, museum piece isn’t a good idea.

I’d rather this than have to consume glm and use vec3.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 27, 2026, 9:20am UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/4 "2026-02-27T09:20:45Z")

</div>

Which would mean, rather than implementing the operators juce would implement overloads for

```auto
template<typename FloatType>
bool approximatelyEqual (
    const juce::Vector3D<FloatType>& a, 
    const juce::Vector3D<FloatType>& b)
{
    return approximatelyEqual (a.x, b.x)
        && approximatelyEqual (a.y, b.y)
        && approximatelyEqual (a.z, b.z);
}

```

And the same for exactlyEqual.

It’s up for discussion, if implementing the operator calling approximatelyEqual is wise or not.

---

<div class="post-metadata">

**Author:** ![nicolasdanet](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nicolasdanet/32/56_2.png) [@nicolasdanet](https://forum.juce.com/u/nicolasdanet)\
**Post date:** [February 27, 2026, 10:20am UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/5 "2026-02-27T10:20:22Z")

</div>

Or check if the difference vector has almost a zero norm (with`lengthIsBelowEpsilon`)?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 27, 2026, 10:38am UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/6 "2026-02-27T10:38:07Z")

</div>

I was thinking about that, but I would think calculating the norm is _slightly_ more expensive than just comparing the components. Not to mention of numerical errors when multiplying and taking the square root.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [February 27, 2026, 2:49pm UTC](https://forum.juce.com/t/fr-vector3d-add-operator/68324/7 "2026-02-27T14:49:36Z")

</div>

I think we’re overcomplicating this.

`operator==/!=` can just be component-wise exact equality - useful for sentinels/tests/known-constructed values, and somewhat consistent with other JUCE geometry types that already have `==/!=` (`Point<>`, `Rectangle<>`).

For float-tolerant comparisons, make it explicit: [Unity does exactly this split](https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Vector3.Equals.html) where `Equals` is exact, and `==` is approximate because floats. Unreal also defines vector equality as [component-wise via `==/!=`](https://unrealarchive.org/wikis/unreal-wiki/Vector.html#Vector_.28in.29equality). And any game engines or apps using `glm::vec3` are subjected to this implementation: [glm/glm/detail/type\_vec3.inl at e7970a8b26732f1b0df9690f7180546f8c30e48e · g-truc/glm · GitHub](https://github.com/g-truc/glm/blob/e7970a8b26732f1b0df9690f7180546f8c30e48e/glm/detail/type_vec3.inl#L782-L797) .

`Vector3D` being the odd one out (especially in the OpenGL module) is just friction.
