public Direction(Point startingPoint, int direction, ISharedDirection sharedDirection, List <float> speedList, float speed) : base(startingPoint, direction, speedList, speed) { this.sharedDirection = sharedDirection; directionComponentLength = DetermineDirectionComponentLength(this.sharedDirection); }
// Find the value of each axis direction component on this direction. protected float DetermineDirectionComponentLength(ISharedDirection sharedDirection) { float firstComponent = sharedDirection.Length[0]; foreach (float componentLength in sharedDirection.Length) { if (componentLength != 0 && componentLength != firstComponent) { throw new Exception("Make sure all the components of a direction length have equal length."); } } return(firstComponent); }
private bool IsNOrMHelper(ISharedDirection firstDirection, ISharedDirection secondDirection, out int numberOfEqualDirectionComponents) { int countEqualDirectionComponent = 0; for (int index = 0; index < firstDirection.Length.Count; index++) { if (firstDirection.Length[index] == secondDirection.Length[index] && firstDirection.Length[index] != 0) { countEqualDirectionComponent++; } } numberOfEqualDirectionComponents = countEqualDirectionComponent; return(countEqualDirectionComponent > 0 && countEqualDirectionComponent < firstDirection.Length.Count); }