# Difference in intended use between the Hypotenuse node and the Vector2dLength node?

**URL:** <https://forums.unrealengine.com/t/difference-in-intended-use-between-the-hypotenuse-node-and-the-vector2dlength-node/442572>\
**Category:** Blueprint\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [February 1, 2019, 9:43pm UTC](https://forums.unrealengine.com/t/difference-in-intended-use-between-the-hypotenuse-node-and-the-vector2dlength-node/442572 "2019-02-01T21:43:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kinloch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kinloch](https://forums.unrealengine.com/u/kinloch)\
**Post date:** [February 1, 2019, 9:43pm UTC](https://forums.unrealengine.com/t/difference-in-intended-use-between-the-hypotenuse-node-and-the-vector2dlength-node/442572/1 "2019-02-01T21:43:44Z")

</div>

As far as I can tell they should be the same mathematically however the 2D vector length node works for all possible input vectors while the hypotenuse node does not for the edge case of both inputs being zero. (UE-69468)  
Are there different intended use cases for these two nodes and is there a reason for using one over the other (aside from the hypotenuse node not working for some values)?

---

<div class="post-metadata">

**Author:** ![Chyros](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chyros](https://forums.unrealengine.com/u/Chyros)\
**Post date:** [February 2, 2019, 2:49am UTC](https://forums.unrealengine.com/t/difference-in-intended-use-between-the-hypotenuse-node-and-the-vector2dlength-node/442572/2 "2019-02-02T02:49:30Z")

</div>

If you look through the source code, **Vector2dLength** (or **Vector2D size** ) represents the _Pythagorean Theorem_ whereas **Hypotenuse** is modified to be safer way to avoid overflow/underflow caused by squaring the width and height (as stated in the implementation comment):

**Vector2dLength** implementation

```
FORCEINLINE float FVector2D::Size() const
{
	return FMath::Sqrt(X*X + Y*Y);
}

```

**Hypotenuse** implementation

```
float UKismetMathLibrary::Hypotenuse(float Width, float Height)
{
	// This implementation avoids overflow/underflow caused by squaring width and height:
	Width = FMath::Abs(Width);
	Height = FMath::Abs(Height);

	float Min = FGenericPlatformMath::Min(Width, Height);
	float Max = FGenericPlatformMath::Max(Width, Height);
	float Ratio = Min / Max;
	return Max * FMath::Sqrt(1.f + Ratio * Ratio);
}

```

As you can see above, **Hypothenuse** has more going on to arrive on the same result with **Vector2dLength**.

As for what to use where, it depends on your needs. If you prefer to be safe, then go with **Hypotenuse** by all means. If you prefer every bit of performance (no matter how unnoticeable it is), then go with **Vector2dLength**.

---

<div class="post-metadata">

**Author:** ![kinloch](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kinloch](https://forums.unrealengine.com/u/kinloch)\
**Post date:** [February 2, 2019, 3:10am UTC](https://forums.unrealengine.com/t/difference-in-intended-use-between-the-hypotenuse-node-and-the-vector2dlength-node/442572/3 "2019-02-02T03:10:23Z")

</div>

Thanks, this answers my question quite well, it also seems to explain why the hypotenuse node fails with width and height of zero.
