Nội dung bài viết ♥
- Vector 2 chiều và Pythago
- Vector 3 chiều
I. Vector 2 chiều và Pythago
Vector2 vector = new Vector2(2, 3);
Các vector tĩnh
Vector2 vector = new Vector2(2, 3);
Vector2 vectorZero = Vector2.zero;
Vector2 vectorOne = Vector2.one;
Vector2 vectorLeft = Vector2.left;
Vector2 vectorRight = Vector2.right;
Debug.Log("Vector (2,3): " +vector);
Debug.Log("Vector Zero " +vectorZero);
Debug.Log("Vector One: " +vectorOne);
Debug.Log("Vector Left: " +vectorLeft);
Debug.Log("Vector Right: " +vectorRight);
- Để tìm kích thước cạnh huyền trong tam giác vuông ta dùng Vector.magnitute
Vector2 vector = new Vector2(3, 4);
Debug.Log("Vector magnitute: " +vector.magnitude);
Kết quả thu được là: 5
II. Vector 3 chiều
- Vector 3 chiều cũng giống như Vector 2
Vector3 vector = new Vector3(3, 4, 12);
Debug.Log("Vector magnitute: " +vector.magnitude);
0 nhận xét:
Đăng nhận xét
Thank you!