From cd080577fc76ad3e287e90c2044064a31d153fe4 Mon Sep 17 00:00:00 2001 From: Oscar Lostes Cazorla Date: Wed, 13 May 2020 23:42:29 +0300 Subject: [PATCH] Introduced Vector2 and Vector3 Square Lenght. --- src/raymath.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/raymath.h b/src/raymath.h index 0eb423a01..dc577d0d8 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -207,6 +207,13 @@ RMDEF float Vector2Length(Vector2 v) return result; } +// Calculate vector square length +RMDEF float Vector2SqrLength(Vector2 v) +{ + float result = (v.x*v.x) + (v.y*v.y); + return result; +} + // Calculate two vectors dot product RMDEF float Vector2DotProduct(Vector2 v1, Vector2 v2) { @@ -401,6 +408,13 @@ RMDEF float Vector3Length(const Vector3 v) return result; } +// Calculate vector square length +RMDEF float Vector3SqrLength(const Vector3 v) +{ + float result = v.x*v.x + v.y*v.y + v.z*v.z; + return result; +} + // Calculate two vectors dot product RMDEF float Vector3DotProduct(Vector3 v1, Vector3 v2) {