万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

Vector3.Angle Unity実行

     public static float Angle(Vector3 from, Vector3 to)
        {
            return Mathf.Acos(Mathf.Clamp(Vector3.Dot(from.normalized, to.normalized), -1f, 1f)) * 57.29578f;
        }
            float judgeAngle = Vector3.Angle(Vector3.zero, Vector3.zero);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.right, Vector3.zero);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.zero, Vector3.right);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.zero, Vector3.right);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.zero, new Vector3(13, 441, 45));
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(new Vector3(13, 441, 45), Vector3.zero);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.forward, Vector3.zero);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.back, Vector3.zero);
            Debug.Log(judgeAngle);

            judgeAngle = Vector3.Angle(Vector3.zero, Vector3.up);
            Debug.Log(judgeAngle);
// => ここまで90

            judgeAngle = Vector3.Angle(Vector3.right, Vector3.left);
            Debug.Log(judgeAngle);
// => 180

            judgeAngle = Vector3.Angle(Vector3.left, Vector3.left);
            Debug.Log(judgeAngle);
// => 0

            judgeAngle = Vector3.Angle(Vector3.right, Vector3.right);
            Debug.Log(judgeAngle);
// => 0