summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/Test/TestMathHelper.cs
blob: 239d8ed922906ff05e60882c5a92ba152320aa80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestMathHelper : MonoBehaviour
{

	public static Vector2 Rotate(Vector2 v, float delta)
	{
		return new Vector2(
			v.x * Mathf.Cos(delta) - v.y * Mathf.Sin(delta),
			v.x * Mathf.Sin(delta) + v.y * Mathf.Cos(delta)
		);
	}

	/// <summary>
	/// ·µ»Ø½Ç¶È
	/// </summary>
	/// <param name="vector2"></param>
	/// <returns></returns>
	public static float Angle(Vector2 vector2)
	{
		return 360 - (Mathf.Atan2(vector2.y, vector2.x) * Mathf.Rad2Deg * Mathf.Sign(vector2.y));
	}

	public static int Check(bool condition)
	{
		return condition ? 1 : 0;
	}

	//public static float Angle(Vector2 vector2)
	//{
	//	if (vector2.x < 0)
	//	{
	//		return 360 - (Mathf.Atan2(vector2.x, vector2.y) * Mathf.Rad2Deg * -1);
	//	}
	//	else
	//	{
	//		return Mathf.Atan2(vector2.x, vector2.y) * Mathf.Rad2Deg;
	//	}
	//}

}