public Vector4 rotatePointAroundPlane(Vector4 point, float angle, RotationPlane plane) { int[] planeCoordinates = Rotation4D.getRotationPlaneIndices(plane); int[] freeCoordinates = new int[2]; int a = 0; for (int i = 0; i < 4; i++) { if (!planeCoordinates.Contains(i)) { freeCoordinates [a] = i; a++; } } float X = point[freeCoordinates [0]]; float Y = point[freeCoordinates [1]]; float newX = X * Mathf.Cos(angle) - Y * Mathf.Sin(angle); float newY = X * Mathf.Sin(angle) + Y * Mathf.Cos(angle); point [freeCoordinates [0]] = newX; point [freeCoordinates [1]] = newY; return(point); }
public static int[] getRotationPlaneIndices(RotationPlane plane) { switch (plane) { case RotationPlane.XY: return(new int[] { 0, 1 }); case RotationPlane.XZ: return(new int[] { 0, 2 }); case RotationPlane.XW: return(new int[] { 0, 3 }); case RotationPlane.YZ: return(new int[] { 1, 2 }); case RotationPlane.YW: return(new int[] { 1, 3 }); case RotationPlane.ZW: return(new int[] { 2, 3 }); default: return(null); } }
// Start is called before the first frame update void Start() { Input.gyro.enabled = true; rotationPlane = FindObjectOfType <RotationPlane>(); }
private void Start() { rotationPlane = FindObjectOfType <RotationPlane>(); }