using System; using UnityEngine; namespace Artngame.TEM { public static class TornadoMath { public static float GetAngle(float x, float y) { float num = Mathf.Atan2(y, x) / MathF.PI * 180f; if (num < 0f) { num += 360f; } return num; } public static Vector3 GetParticlePos(Vector3 centerPos, float angle, float radius, float rotationSpeed) { angle += rotationSpeed * Time.deltaTime; float f = angle * (MathF.PI / 180f); float x = centerPos.x + radius * Mathf.Cos(f); float z = centerPos.z + radius * Mathf.Sin(f); return new Vector3(x, 0f, z); } public static Vector3 GetParticleVel(float angle, float radius, float rotationSpeed) { angle += rotationSpeed * Time.deltaTime; float f = angle * (MathF.PI / 180f); float x = Mathf.Cos(f) - radius * Mathf.Sin(f); float z = Mathf.Sin(f) + radius * Mathf.Cos(f); return new Vector3(x, 0f, z); } public static float CalculateProgress(Vector3 from, Vector3 to, Vector3 current) { Vector3 rhs = to - from; return Vector3.Dot(current - from, rhs) / rhs.sqrMagnitude; } public static Vector3 CheckRadius(Vector3 particlePos, Vector3 centerPos, float wantedRadius) { particlePos.y = 0f; centerPos.y = 0f; float magnitude = (particlePos - centerPos).magnitude; Vector3 normalized = (particlePos - centerPos).normalized; if (magnitude < wantedRadius) { particlePos += normalized * (wantedRadius - magnitude); } return particlePos; } } }