public Vector5 rotatePointAroundSpace(Vector5 point, float angle, RotationSpace5D space) { int[] spaceCoordinates = Rotation5D.getRotationSpaceIndices(space); int[] freeCoordinates = new int[2]; int a = 0; for (int i = 0; i < 5; i++) { if (!spaceCoordinates.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[] getRotationSpaceIndices(RotationSpace5D space) { switch (space) { case RotationSpace5D.XYZ: return(new int[] { 0, 1, 2 }); case RotationSpace5D.XYW: return(new int[] { 0, 1, 3 }); case RotationSpace5D.XYV: return(new int[] { 0, 1, 4 }); case RotationSpace5D.XZW: return(new int[] { 0, 2, 3 }); case RotationSpace5D.XZV: return(new int[] { 0, 2, 4 }); case RotationSpace5D.XWV: return(new int[] { 0, 3, 4 }); default: return(null); } }