Vector4 GetRotatedVertex(Axis4D axis, Vector4 v, float s, float c) { switch (axis) { case Axis4D.xy: return(RotateAroundXY(v, s, c)); case Axis4D.xz: return(RotateAroundXZ(v, s, c)); case Axis4D.xw: return(RotateAroundXW(v, s, c)); case Axis4D.yz: return(RotateAroundYZ(v, s, c)); case Axis4D.yw: return(RotateAroundYW(v, s, c)); case Axis4D.zw: return(RotateAroundZW(v, s, c)); } return(new Vector4(0, 0, 0, 0)); }
/// <summary> /// Rotate a vertex v around an axis for an angle theta, in degrees. /// </summary> /// <param name="v"></param> /// <param name="axis"></param> /// <param name="theta"></param> /// <returns></returns> public static Vector4 GetRotatedVertex(this Vector4 v, Axis4D axis, float theta) { if (theta % 360 == 0) { return(v); } switch (axis) { case Axis4D.xy: return(v.rotate(right, up, theta)); case Axis4D.xz: return(v.rotate(right, forward, theta)); case Axis4D.xw: return(v.rotate(right, wPos, theta)); case Axis4D.yz: return(v.rotate(up, forward, theta)); case Axis4D.yw: return(v.rotate(up, wPos, theta)); case Axis4D.zw: return(v.rotate(forward, wPos, theta)); default: return(Vector4.zero); } }
Vector4 GetRotatedVertex(Axis4D axis, Vector4 v, float s, float c) // Creates a vector 4 that holds the axis from our list of axis's, a vector4, and two floats { switch (axis) { // Creates our different cases for each rotations case Axis4D.xy: return(RotateAroundXY(v, s, c)); case Axis4D.xz: return(RotateAroundXZ(v, s, c)); case Axis4D.xw: return(RotateAroundXW(v, s, c)); case Axis4D.yz: return(RotateAroundYZ(v, s, c)); case Axis4D.yw: return(RotateAroundYW(v, s, c)); case Axis4D.zw: return(RotateAroundZW(v, s, c)); } return(new Vector4(0, 0, 0, 0)); // Returns a Vector 4 }
void AddToRotationDictionary(Axis4D axis, float theta) { for (int i = 0; i < rotation.Length; i++) { RotationParams rp = rotation[i]; if (rp.axis == axis) { rp.amount += theta; if (rp.amount > 360) { rp.amount -= 360; } } } }
public float GetRotation(Axis4D axis) { return rotation[axis] % 360f; }
void Rotate(Axis4D axis, float theta) { AddToRotationDictionary(axis, theta); ApplyRotationToVerts(); }
Vector4 GetRotatedVertex(Axis4D axis, Vector4 v, float s, float c) { switch (axis) { case Axis4D.xy: return RotateAroundXY(v, s, c); break; case Axis4D.xz: return RotateAroundXZ(v, s, c); break; case Axis4D.xw: return RotateAroundXW(v, s, c); break; case Axis4D.yz: return RotateAroundYZ(v, s, c); break; case Axis4D.yw: return RotateAroundYW(v, s, c); break; case Axis4D.zw: return RotateAroundZW(v, s, c); break; } return new Vector4(0, 0, 0, 0); }
void AddToRotationDictionary(Axis4D axis, float theta) // Creates our function, requires an axis and a float { rotation [axis] = (rotation [axis] + theta); // Makes the rotation value for our axis = to the axis plus our theta float }
void Rotate(Axis4D axis, float theta) // Creates our Rotate function, that requires an axis and a float (theta) { AddToRotationDictionary(axis, theta); // Calls our AddToRotationDictionary function ApplyRotationToVerts(); // Calls our ApplyRotationToVerts Function }
/// <summary> /// Gets a 64-bit integer that represents the number of elements in the specified dimension of the array. /// </summary> /// <typeparam name="T">The type of values stored in the array.</typeparam> /// <param name="array">The array.</param> /// <param name="dimension">The dimension whose length needs to be determined.</param> /// <returns>A 64-bit integer that represents the number of elements in the specified dimension.</returns> public static long GetLongLength <T>(this T[,,,] array, Axis4D dimension) { Contracts.Requires.That(array != null); return(array.GetLongLength((int)dimension)); }
void AddToRotationDictionary(Axis4D axis, float theta) { rotation [axis] = (rotation [axis] + theta); }
public RotationParams(Axis4D axis, float amount) { this.axis = axis; this.amount = amount; }
/// <summary> /// Gets the index of the last element of the specified dimension in the array. /// </summary> /// <typeparam name="T">The type of values stored in the array.</typeparam> /// <param name="array">The array.</param> /// <param name="dimension">The dimension whose upper bound needs to be determined.</param> /// <returns> /// The index of the last element of the specified dimension in the array, or -1 if the specified dimension is empty. /// </returns> public static int GetUpperBound <T>(this T[,,,] array, Axis4D dimension) { Contracts.Requires.That(array != null); return(array.GetUpperBound((int)dimension)); }
void AddToRotationDictionary(Axis4D axis, float theta) { rotation[axis] = (rotation[axis] + theta); }
/// <summary> /// Rotate around a single plane /// </summary> /// <param name="rotationPlane">The plane that stays constant</param> /// <param name="degrees">The amount of degrees to rotate by</param> public void Rotate(Axis4D rotationPlane, float degrees) { rotation.Add((int)rotationPlane, degrees); }
/// <summary> /// Gets the current index of the last slot of the specified dimension within the specified bounds. /// </summary> /// <param name="bounds">The bounds to check against.</param> /// <param name="axis">The axis of the dimension whose ending index needs to be determined.</param> /// <returns> /// The current index of the last slot of the specified dimension. /// </returns> public static int GetCurrentUpperBound(this IDynamicIndexingBounds<Index4D> bounds, Axis4D axis) { Contracts.Requires.That(bounds != null); return bounds.GetCurrentUpperBound((int)axis); }
/// <summary> /// Gets the coordinate value or index of a particular dimension. /// </summary> /// <param name="axis">The axis of the dimension whose coordinate needs to be determined.</param> /// <returns>The value of the dimensional coordinate.</returns> public int this[Axis4D axis] => this[(int)axis];
/// <summary> /// Gets the index of the first valid slot of the specified dimension within the specified bounds. /// </summary> /// <param name="bounds">The bounds to check against.</param> /// <param name="axis">The axis of the dimension whose starting index needs to be determined.</param> /// <returns> /// The index of the first slot of the specified dimension. /// </returns> public static int GetLowerBound(this IIndexingBounds <Index4D> bounds, Axis4D axis) { Contracts.Requires.That(bounds != null); return(bounds.GetLowerBound((int)axis)); }