PlaneUtils.cs 761 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public static class PlaneUtils
  5. {
  6. public static Vector3[] GetFourPlanePoints(Vector3 position, float angle)
  7. {
  8. Vector3[] points = new Vector3[4];
  9. float cosAngle = Mathf.Cos(angle * Mathf.Deg2Rad);
  10. float sinAngle = Mathf.Sin(angle * Mathf.Deg2Rad);
  11. Vector3 rightUnit = Vector3.right * cosAngle * 2;
  12. Vector3 forwardUnit = Vector3.forward * sinAngle * 2;
  13. points[0] = position + rightUnit + forwardUnit + Vector3.up;
  14. points[1] = points[0] + Vector3.down * 2;
  15. points[2] = position - rightUnit - forwardUnit + Vector3.down;
  16. points[3] = points[2] + Vector3.up * 2;
  17. return points;
  18. }
  19. }