Files
Cielonos/Assets/OtherPlugins/Le Tai's Asset/Common/Editor/MathCustom.cs

25 lines
608 B
C#
Raw Normal View History

2025-12-08 05:27:53 -05:00
using UnityEngine;
namespace LeTai.Common.Editor
{
public static class MathCustom
{
public static float VecToAngle360(Vector2 from, Vector2 to)
{
float angle = Vector2.SignedAngle(from, to);
return angle < 0 ? 360 + angle : angle;
}
public static Vector2 Angle360ToVec(float angle, Vector2 zeroVector)
{
float sin = Mathf.Sin(angle * Mathf.Deg2Rad);
float cos = Mathf.Cos(angle * Mathf.Deg2Rad);
return new Vector2(
zeroVector.x * cos - zeroVector.y * sin,
zeroVector.x * sin + zeroVector.y * cos
);
}
}
}