From de29c4a6cdb97af038a76b098626e7736d56961e Mon Sep 17 00:00:00 2001 From: tvillegas98 Date: Wed, 18 Dec 2024 11:58:06 -0300 Subject: [PATCH] chore: use :math library from erlang --- apps/bot_manager/lib/math/vector.ex | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/bot_manager/lib/math/vector.ex b/apps/bot_manager/lib/math/vector.ex index 09b8b9f4e..7b1c8aab0 100644 --- a/apps/bot_manager/lib/math/vector.ex +++ b/apps/bot_manager/lib/math/vector.ex @@ -33,9 +33,9 @@ defmodule BotManager.Math.Vector do # Using the rotation matrix def rotate_by_degrees(%{x: x, y: y}, angle_in_degrees) do - angle_in_radians = Math.deg2rad(angle_in_degrees) - x = x * Math.cos(angle_in_radians) - y * Math.sin(angle_in_radians) - y = x * Math.sin(angle_in_radians) + y * Math.cos(angle_in_radians) + angle_in_radians = deg2rad(angle_in_degrees) + x = x * :math.cos(angle_in_radians) - y * :math.sin(angle_in_radians) + y = x * :math.sin(angle_in_radians) + y * :math.cos(angle_in_radians) %{ x: x, @@ -51,4 +51,9 @@ defmodule BotManager.Math.Vector do y: y / distance } end + + + def deg2rad(deg) do + deg * :math.pi / 180 + end end