public void GetStickers(MegaImageProp properties, int pieceNum) { var tempStickers = new List <Sticker>(); var tempCoords = new List <CoordPair>(); var angle = MegaImageProp.LARGEANGLE * (pieceNum - 0.5); var angleChange = ((MegaImageProp.LARGEANGLE / 2) - MegaImageProp.SMALLANGLE) * 2; tempCoords.Add(CoordPair.CartesianFromPolar(properties.CenterDist, angle, properties.Center)); angle += MegaImageProp.SMALLANGLE; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); angle += angleChange; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); angle += MegaImageProp.SMALLANGLE; tempCoords.Add(CoordPair.CartesianFromPolar(properties.CenterDist, angle, properties.Center)); tempStickers.Add(new Sticker(tempCoords, properties.EdgeStickerDefs[pieceNum][0])); tempCoords.Clear(); angle = MegaImageProp.LARGEANGLE * (pieceNum - 0.5); angle += MegaImageProp.SMALLANGLE; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); angle += angleChange; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); angle += properties.SideAngle - angleChange / 2; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortSideDist, angle, properties.Center)); angle -= properties.SideAngle * 2; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortSideDist, angle, properties.Center)); tempStickers.Add(new Sticker(tempCoords, properties.EdgeStickerDefs[pieceNum][1])); Stickers = tempStickers.ToArray(); }
public void SpawnEnemy(CoordPair coords) { int r = Mathf.FloorToInt(Random.value * 2.99f); if (r == 0) { allyEntities.Add(new Explorer(matrix[coords.x, coords.y], 2)); } else if (r == 1) { allyEntities.Add(new Attacker(matrix[coords.x, coords.y], 2)); } else if (r == 2) { allyEntities.Add(new Defender(matrix[coords.x, coords.y], 2)); } Entity entity = enemyEntities[enemyEntities.Count - 1]; entity.GetCell().Fill(entity); Transform aux = entity.GetCell().gameObject.GetComponent <Transform>(); GameObject newEntity = Instantiate(entity.prefab, aux.position, aux.rotation); newEntity.GetComponent <TacticsMove>().soldier = (Soldier)entity; ((Soldier)entity).move = newEntity.GetComponent <TacticsMove>(); newEntity.GetComponent <TacticsMove>().enabled = true; }
public void PathfindDistanceAll() { foreach (var source in AllPaths.AllCoords) { AllPaths[source] = new HexMap <Path>(Game.Size); PathfindDistanceOnlyFrom(AllPaths[source], source); } _precomputedPaths.Clear(); foreach (var source in AllPaths.AllCoords) { foreach (var destination in AllPaths.AllCoords) { var key = CoordPair.Build(source, destination); if (_precomputedPaths.ContainsKey(key)) { continue; } var path = PathFromSourceToTarget(source, destination); _precomputedPaths.Add(key, path); } } }
Cell FindNearestAdjacent(Cell target) { Cell nearest = null; float distance = Mathf.Infinity; Cell c = this.GetCurrentCell(); CoordPair cPos = c.GetCoordinates(); foreach (Cell adjacent in target.adjacencyList) { CoordPair adjacentPos = adjacent.GetCoordinates(); Vector2 adjacentVec = new Vector2(adjacentPos.x, adjacentPos.y); Vector2 cVec = new Vector2(cPos.x, cPos.y); float d = Vector2.Distance(cVec, adjacentVec); if (d < distance) { distance = d; nearest = adjacent; } } return(nearest); }
public void UpdateSums(CoordPair coordPair, int value) { columnSum[coordPair.x] += value; rowSum[coordPair.y] += value; lineSum.UpdateColumnAndRowText(true, coordPair.x, columnSum[coordPair.x]); lineSum.UpdateColumnAndRowText(false, coordPair.y, rowSum[coordPair.y]); }
public Sticker(char color, CoordPair Start, double angle, bool cornerSize, SkewbImageProp properties) { /// <summary> /// Constructs corner. /// </summary> Color = properties.ColorScheme.GetFace(color); SetCoord(Start, angle, cornerSize, properties); }
public KiloImageProp(KiloImageConfiguration configs) : base(configs) { SetStickerDefs(configs.Scheme, configs.StickerDefs); ImageLength = configs.ImageLength; SetDistances(); ImageSize = new Tuple <double, double>(ImageLength, LongSideDist + ShortSideDist); // Both distance add up to the height of the pentagon Center = new CoordPair(ImageLength / 2, LongSideDist); // LongSideDist is the distance from the top of the image to the center of the pentagon }
public void GetSticker(MegaImageProp properties) { var tempCoords = new List <CoordPair>(); var angle = MegaImageProp.LARGEANGLE / 2; while (angle < (Math.PI * 2)) { tempCoords.Add(CoordPair.CartesianFromPolar(properties.CenterDist, angle, properties.Center)); angle += MegaImageProp.LARGEANGLE; } Stickers = new[] { new Sticker(tempCoords, properties.CenterColor) }; }
private void SetCoord(CoordPair Start, double angle, bool cornerSize, SkewbImageProp properties) { var tempCoordinates = new List <CoordPair>(); var cornerDist = properties.ShortFaceDist; tempCoordinates.Add(Start); tempCoordinates.Add(CoordPair.CartesianFromPolar(cornerDist, angle, Start)); tempCoordinates.Add(CoordPair.CartesianFromPolar(cornerDist, angle - (cornerSize ? Math.PI * 120 / 180 : Math.PI * 60 / 180), Start)); Coordinates = tempCoordinates.ToArray(); }
public void MoveEntity(CoordPair from, CoordPair to) //Llamar a este método cuando se mueva un soldado para actualizar la matriz { Entity entity = matrix[from.x, from.y].GetEntity(); if (entity is Soldier) { matrix[from.x, from.y].Empty(); matrix[to.x, to.y].Fill(entity); UpdateInfluenceMap(); UpdateVisionMap(); UpdateDiscoveryMap(); entity.SetCell(matrix[to.x, to.y]); } }
public SkewbImageProp(SkewbImageConfiguration configs) : base(configs) { DFace = configs.Dface; ShortFaceDist = (ImageLength / 8) / Math.Cos(Math.PI * 30 / 180); LongFaceDist = ShortFaceDist * 2; var yAboveCenter = (ImageLength / 8) * Math.Tan(Math.PI * 30 / 180) * 6; var yBelowCenter = LongFaceDist * (DFace ? 2 : 1); ImageSize = new Tuple <double, double>(ImageLength, yAboveCenter + yBelowCenter); Center = new CoordPair(ImageLength / 2, yAboveCenter); AddColorScheme(configs.ColorScheme); }
public void GetStickers(MegaImageProp properties, int pieceNum) { var tempStickers = new List <Sticker>(); var tempCoords = new List <CoordPair>(); var angle = MegaImageProp.LARGEANGLE * (pieceNum + 0.5); tempCoords.Add(CoordPair.CartesianFromPolar(properties.CenterDist, angle, properties.Center)); angle -= MegaImageProp.SMALLANGLE; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); angle += MegaImageProp.SMALLANGLE; tempCoords.Add(CoordPair.CartesianFromPolar(properties.LongFaceDist, angle, properties.Center)); angle += MegaImageProp.SMALLANGLE; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); tempStickers.Add(new Sticker(tempCoords, properties.CornerStickerDefs[pieceNum][0])); tempCoords.Clear(); angle = MegaImageProp.LARGEANGLE * (pieceNum + 0.5); tempCoords.Add(CoordPair.CartesianFromPolar(properties.LongFaceDist, angle, properties.Center)); tempCoords.Add(CoordPair.CartesianFromPolar(properties.LongSideDist, angle, properties.Center)); angle -= MegaImageProp.LARGEANGLE / 2 - properties.SideAngle; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortSideDist, angle, properties.Center)); angle -= MegaImageProp.SMALLANGLE + properties.SideAngle - MegaImageProp.LARGEANGLE / 2; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); tempStickers.Add(new Sticker(tempCoords, properties.CornerStickerDefs[pieceNum][1])); tempCoords.Clear(); angle = MegaImageProp.LARGEANGLE * (pieceNum + 0.5); tempCoords.Add(CoordPair.CartesianFromPolar(properties.LongFaceDist, angle, properties.Center)); tempCoords.Add(CoordPair.CartesianFromPolar(properties.LongSideDist, angle, properties.Center)); angle += MegaImageProp.LARGEANGLE / 2 - properties.SideAngle; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortSideDist, angle, properties.Center)); angle += MegaImageProp.SMALLANGLE + properties.SideAngle - MegaImageProp.LARGEANGLE / 2; tempCoords.Add(CoordPair.CartesianFromPolar(properties.ShortFaceDist, angle, properties.Center)); tempStickers.Add(new Sticker(tempCoords, properties.CornerStickerDefs[pieceNum][2])); Stickers = tempStickers.ToArray(); }
} // last sticker is the center public Face(char[] stickersColors, double angle, CoordPair start, SkewbImageProp properties) { var tempStickers = new List <Sticker>(); var large = true; foreach (var color in stickersColors.Take(4)) { tempStickers.Add(new Sticker(color, start, angle, large, properties)); start = CoordPair.CartesianFromPolar(properties.LongFaceDist, angle, start); angle -= large ? Math.PI * 120 / 180 : Math.PI * 60 / 180; large = !large; } tempStickers.Add(new Sticker(stickersColors.Last(), tempStickers.ToArray(), properties)); Stickers = tempStickers.ToArray(); }
public bool CanBePlaced(Transform groupParent) { int n; if (groupParent == null || (n = groupParent.childCount) == 0) { return(false); } CoordPair[] coordinatePairs = new CoordPair[n]; Vector3 pos0 = groupParent.GetChild(0).localPosition; for (int i = 0; i < n; i++) { Vector3 relativePosition = (groupParent.GetChild(i).localPosition - pos0) / gridManager.cellSize; coordinatePairs[i] = new CoordPair((int)relativePosition.x, (int)relativePosition.y); } for (int x = 0; x < gridManager.Width; x++) { for (int y = 0; y < gridManager.Height; y++) { bool placable = true; foreach (CoordPair pair in coordinatePairs) { if (gridManager.GetCellValue(x + pair.x, y + pair.y) != 0) { placable = false; break; } } if (placable) { return(true); } } } return(false); }
public void SetCoordFromPolar(double dist, double coordAngle) { CoordPair center = new CoordPair(); double angle = 0; if (PiecePosition < 24) { center = new CoordPair(Properties.ImageLength / 2, Properties.ImageLength / 2); angle = ((coordAngle + 1) % 24) * Properties.AngleUnits; } else { center = new CoordPair(Properties.ImageLength / 2, Properties.ImageLength / 2, Properties.XOffset, Properties.YOffset); var configs = (Sq1ImageConfiguration)Properties.Configs; angle = (coordAngle + 11) % 24 * Properties.AngleUnits * -1; } _coords.Add(CoordPair.CartesianFromPolar(dist, angle, center)); }
public void ComputeAdjacencyList(CoordPair coords) { matrix[coords.x, coords.y].Reset(); if (coords.x > 0 && matrix[coords.x - 1, coords.y].GetTerrain() != Cell.Terrain.Obstacle && matrix[coords.x - 1, coords.y].GetEntity() == null) { matrix[coords.x, coords.y].adjacencyList.Add(matrix[coords.x - 1, coords.y]); } if (coords.x < size - 1 && matrix[coords.x + 1, coords.y].GetTerrain() != Cell.Terrain.Obstacle && matrix[coords.x + 1, coords.y].GetEntity() == null) { matrix[coords.x, coords.y].adjacencyList.Add(matrix[coords.x + 1, coords.y]); } if (coords.y > 0 && matrix[coords.x, coords.y - 1].GetTerrain() != Cell.Terrain.Obstacle && matrix[coords.x, coords.y - 1].GetEntity() == null) { matrix[coords.x, coords.y].adjacencyList.Add(matrix[coords.x, coords.y - 1]); } if (coords.y < size - 1 && matrix[coords.x, coords.y + 1].GetTerrain() != Cell.Terrain.Obstacle && matrix[coords.x, coords.y + 1].GetEntity() == null) { matrix[coords.x, coords.y].adjacencyList.Add(matrix[coords.x, coords.y + 1]); } }
private void CreateFacees(SkewbImageConfiguration configs) { var stickerColors = ParseDefs(configs.StickerDefs); if (stickerColors.Length == 6 || (Properties.DFace && stickerColors.Length == 5)) { var tempFaces = new List <Face>(); for (int i = 0; i < 3; i++) { var angle = Math.PI * 120 / 180 * i; tempFaces.Add(new Face(stickerColors[i], angle, Properties.Center, Properties)); if (i != 0 || Properties.DFace) { tempFaces.Add(new Face(stickerColors[i + 3], (i == 0 ? 0 : Math.PI * 240 / 180) , CoordPair.CartesianFromPolar(Properties.LongFaceDist, angle, Properties.Center), Properties)); } } Faces = tempFaces.ToArray(); } }
public void UpdateDiscoveryMap() { foreach (Entity entity in allyEntities) { Cell cell = entity.GetCell(); CoordPair pos = cell.GetCoordinates(); if (entity is Explorer) { for (int x = pos.x - 10; x <= pos.x + 10; x++) { for (int y = pos.y - 10; y <= pos.y + 10; y++) { if (x >= 0 && x < size && y >= 0 && y < size) { if (!matrix[x, y].discovery) { matrix[x, y].discovery = Vector2.Distance(new Vector2(x, y), new Vector2(pos.x, pos.y)) < 10; } } } } } else { for (int x = pos.x - 6; x <= pos.x + 6; x++) { for (int y = pos.y - 6; y <= pos.y + 6; y++) { if (x >= 0 && x < size && y >= 0 && y < size) { if (!matrix[x, y].discovery) { matrix[x, y].discovery = Vector2.Distance(new Vector2(x, y), new Vector2(pos.x, pos.y)) < 6; } } } } } UpdateMeshes(); } }
private CoordPair?GetBoardSpaceClick(GameBoardConfig config, Point mouseClick) { Rect board = config.GameBoard; if (mouseClick.X < board.X || mouseClick.X > board.X + board.Width) { return(null); } else if (mouseClick.Y < board.Y || mouseClick.Y > board.Y + board.Height) { return(null); } double totalWidth = config.SpaceWidth + 2 * config.SpaceXMargin; double totalHeight = config.SpaceHeight + 2 * config.SpaceYMargin; double rootedX = mouseClick.X - board.X; double rootedY = mouseClick.Y - board.Y; int indexX = (int)Math.Floor(rootedX / totalWidth); int indexY = (int)Math.Floor(rootedY / totalHeight); double coordX = board.X + config.SpaceXMargin + totalWidth * indexX; double coordY = board.Y + config.SpaceYMargin + totalHeight * indexY; if (mouseClick.X < coordX || mouseClick.X > coordX + config.SpaceWidth) { return(null); } else if (mouseClick.Y < coordY || mouseClick.Y > coordY + config.SpaceHeight) { return(null); } CoordPair pair = new CoordPair(); pair.indexX = indexX; pair.indexY = indexY; return(pair); }
public void TrySettleGroup(Transform groupParent) { int snapCount = 0, childCount = groupParent.childCount; CoordPair[] coordPairs = new CoordPair[groupParent.childCount]; for (int i = 0; i < childCount; i++) { int x, y; if (gridManager.WorldToGridPosition(groupParent.GetChild(i).position, out x, out y) && gridManager.GetCellValue(x, y) == 0) { coordPairs[i] = new CoordPair(x, y); snapCount++; } } if (snapCount == childCount) { StartCoroutine(SettleGroup(groupParent, coordPairs)); } }
void FindNearestTarget() { List <Entity> allyEntities = map.GetAllyEntities(); Cell nearest = null; float distance = Mathf.Infinity; foreach (Entity allyEntity in allyEntities) //buscamos entre todas las entidades del jugador la que esta mas cerca { if (allyEntity is Soldier) // si no es una ciudad { //Mejorar version a -> Si la cell esta dentro de la lista de cells del rango... o si la cell esta dentro del rango de vision... Cell allyCell = allyEntity.GetCell(); //cell del enemigo player Cell enemyCell = this.GetCurrentCell(); CoordPair allyPos = allyCell.GetCoordinates(); CoordPair enemyPos = enemyCell.GetCoordinates(); Vector2 allyVec = new Vector2(allyPos.x, allyPos.y); Vector2 enemyVec = new Vector2(enemyPos.x, enemyPos.y); float d = Vector2.Distance(enemyVec, allyVec); if (d < distance) { distance = d; nearest = allyCell; } } } target = FindNearestAdjacent(nearest); //print("Coord de la pinchada -> x: " + nearest.GetCoordinates().x + " y: " + nearest.GetCoordinates().y); }
public void PrecomputeCubeLinedraw() { EmptyCoords.Clear(); _visibility.Clear(); _visibilityLines.Clear(); foreach (var a in AllCoords) { if (this[a] == HexType.Empty) { EmptyCoords.Add(a); } foreach (var b in AllCoords) { var result = ComputeCubeLinedraw(a, b); var line = result.Select(x => x.ToAxial()).ToList(); var key = CoordPair.Build(a, b); _visibilityLines[key] = line; var targetVisible = true; foreach (var coord in line) { if (this[coord] != HexType.Empty) { targetVisible = false; break; } } _visibility[key] = targetVisible; } } }
public MegaImageProp(MegaImageConfiguration configs) : base(configs) { SetStickerDefs(configs.Scheme, configs.StickerDefs); ImageLength = configs.ImageLength; var centerX = ImageLength / 2; LongSideDist = centerX / Math.Cos(LARGEANGLE / 4); LongFaceDist = 0.8 * LongSideDist; CenterDist = LongFaceDist * 0.4; var belowCenterY = Math.Cos(LARGEANGLE / 2) * LongSideDist; Center = new CoordPair(centerX, LongSideDist); ImageSize = new Tuple <double, double>(ImageLength, Center.Y + belowCenterY); ShortFaceDist = Math.Sin(Math.PI * 54 / 180) * LongFaceDist / Math.Sin(Math.PI * 126 / 180 - SMALLANGLE); var edgeHalfWidth = Math.Sin(LARGEANGLE / 2) * CenterDist * 0.75; ShortSideDist = Math.Sqrt(Math.Pow(edgeHalfWidth, 2) + Math.Pow(belowCenterY, 2)); SideAngle = Math.Acos(belowCenterY / ShortSideDist); }
public List <AxialCoord> AxialLinedraw(AxialCoord a, AxialCoord b) { return(_visibilityLines[CoordPair.Build(a, b)]); }
public void UpdateVisionMap() { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { matrix[i, j].vision = 0; } } foreach (Entity entity in allyEntities) { Cell cell = entity.GetCell(); CoordPair pos = cell.GetCoordinates(); if (entity is Explorer) { for (int x = pos.x - 9; x <= pos.x + 9; x++) { for (int y = pos.y - 9; y <= pos.y + 9; y++) { if (x >= 0 && x < size && y >= 0 && y < size) { float distance = Vector2.Distance(new Vector2(x, y), new Vector2(pos.x, pos.y)); float newVision; if (distance <= 5) { newVision = 1; } else { newVision = (5 - (distance - 5)) / 5; } if (newVision > matrix[x, y].vision) { matrix[x, y].vision = newVision; } } } } } else { for (int x = pos.x - 5; x <= pos.x + 5; x++) { for (int y = pos.y - 5; y <= pos.y + 5; y++) { if (x >= 0 && x < size && y >= 0 && y < size) { float distance = Vector2.Distance(new Vector2(x, y), new Vector2(pos.x, pos.y)); float newVision; if (distance <= 3) { newVision = 1; } else { newVision = (3 - (distance - 3)) / 3; } if (newVision > matrix[x, y].vision) { matrix[x, y].vision = newVision; } } } } } } }
public void SetCoordinates(CoordPair coords) { coordinates = coords; }
public Cell(CoordPair coordinates) { this.coordinates = coordinates; }
public List <CoordPair> CreateBendingMomentModel( float PointLoadingLocation, float PointLoadingMagnitude, float TriangularDistributedLoadingLocation, float TriangularDistributedLoadingMagnitude, float RectangularDistributedLoadingLocation, float RectangularDistributedLoadingMagnitude, float FreeMomentLocation, float FreeMomentMagnitude, float PinSupportLocation, float RollerSupportLocation, float FixedSupportLocation, float LengthOfBeam, bool IncludePinSupport, bool IncludeRollerSupport, bool IncludeFixedSupport ) { // Declare and initialize all complex variables float PointLoadMoment = (float)Math.Round((PointLoadingLocation * PointLoadingMagnitude), 2); float TriangularDistForce = (float).5 * TriangularDistributedLoadingMagnitude * TriangularDistributedLoadingLocation; float TriangularDistForceLocation = (float)Math.Round((float)(.666666666666666666667 * TriangularDistributedLoadingLocation), 2); float TrinagularMoment = TriangularDistForce * TriangularDistForceLocation; float RectangularDistForce = RectangularDistributedLoadingMagnitude * RectangularDistributedLoadingLocation; float RectangularDistForceLocation = (float).5 * RectangularDistributedLoadingLocation; float RectangularMoment = RectangularDistForce * RectangularDistForceLocation; // Support Reactions // Do moment solving for one of the forces right here. Get ratio of pin force to other forces int UsePinSupport = IncludePinSupport ? 1 : 0; int UseRollerSupport = IncludeRollerSupport ? 1 : 0; int UseFixedSupport = IncludeFixedSupport ? 1 : 0; float[,] matrix = { { UsePinSupport, UseRollerSupport, UseFixedSupport }, { PinSupportLocation, RollerSupportLocation, FixedSupportLocation } }; float knownForceMag = -1 * (PointLoadingMagnitude + RectangularDistForce + TriangularDistForce); float knownMomentMag = -1 * (PointLoadMoment + RectangularMoment + TrinagularMoment); float[,] RightSideMoment = { { knownForceMag }, { knownMomentMag } }; float[,] MomentReaction = Matrix.Solve(matrix, RightSideMoment, leastSquares: true); float YPinReaction = MomentReaction[0, 0]; float YRollerReaction = MomentReaction[1, 0]; // No X reaction, No moment reaction float YFixedReaction = MomentReaction[2, 0]; // The exact same coordinate pairs as the Shear Force Diagram List <CoordPair> Result = new List <CoordPair>() { new CoordPair { XCoord = PointLoadingLocation, YCoord = PointLoadingMagnitude }, new CoordPair { XCoord = TriangularDistForceLocation, YCoord = TriangularDistForce }, new CoordPair { XCoord = RectangularDistForceLocation, YCoord = RectangularDistForce }, new CoordPair { XCoord = LengthOfBeam, YCoord = 0 } }; CoordPair PinSupportPair = new CoordPair { XCoord = PinSupportLocation, YCoord = YPinReaction }; if (IncludePinSupport) { Result.Add(PinSupportPair); } CoordPair RollerSupportPair = new CoordPair { XCoord = RollerSupportLocation, YCoord = YRollerReaction }; if (IncludeRollerSupport) { Result.Add(RollerSupportPair); } CoordPair FixedSupportPair = new CoordPair { XCoord = FixedSupportLocation, YCoord = YFixedReaction }; if (IncludeFixedSupport) { Result.Add(FixedSupportPair); } Result.Sort(delegate(CoordPair x, CoordPair y) // Sorts all of the coord pairs by x coordinate so lower x coordinate pairs display first { return(x.XCoord.CompareTo(y.XCoord)); }); // Run through the list and add up the Y coordinates (Forces) float CurYCoord = 0; float PrevYCoord = 0; foreach (var CoordPair in Result) { PrevYCoord = CurYCoord; CoordPair.YCoord += PrevYCoord; CurYCoord = CoordPair.YCoord; } CoordPair zeroPair = new CoordPair { XCoord = 0, YCoord = 0 }; CoordPair FreeMoment = new CoordPair { XCoord = FreeMomentLocation, YCoord = FreeMomentMagnitude }; Result.RemoveAll(pair => (pair.XCoord == 0 & pair.YCoord == 0)); // Removes all invalid entries that are generated on startup if (freeMomentLocation != 0) { Result.Insert(0, zeroPair); // Sets the inital coord point on the graph ALWAYS equal to (0,0) } else { Result.Insert(0, FreeMoment); } // Shift the X Coordinates to the right by one to connect plot the right points (connect the dots) for (int i = 1; i < (Result.Count - 1); i++) { Result[i].XCoord = Result[i + 1].XCoord; } Result.RemoveAt(Result.Count - 1); Result[Result.Count - 1].YCoord = 0; // * CHECK WITH THE PROFESSOR Moment diagram will always return to the zero location? // Multiply the forces by the distances to get the moment y coordinates float LastXCoord = 0; for (int i = 1; i < (Result.Count - 1); i++) // Moves the X coordinate over one to plot the right point { Result[i].YCoord = Result[i].YCoord * (Result[i].XCoord - LastXCoord); LastXCoord = Result[i].XCoord; } // Add free moment and sort it into the moment coordinate pairs if (FreeMoment.XCoord != 0 & FreeMoment.YCoord != 0) { Result.Add(FreeMoment); Result.Sort(delegate(CoordPair x, CoordPair y) { return(x.XCoord.CompareTo(y.XCoord)); }); } // Do one last run through of the list and sum the moments for each point CurYCoord = 0; PrevYCoord = 0; for (int i = 0; i < (Result.Count - 1); i++) { PrevYCoord = CurYCoord; Result[i].YCoord += PrevYCoord; CurYCoord = Result[i].YCoord; } // Removes all invalid coordinate sets where the location is greater than the length of the beam CoordPair RectifyEndPoint = new CoordPair { XCoord = LengthOfBeam, YCoord = 0 }; if (Result[Result.Count - 1].XCoord > LengthOfBeam) { Result.RemoveAll(pair => (pair.XCoord > LengthOfBeam)); Result[Result.Count - 1] = RectifyEndPoint; } return(Result); }
public IList <AxialCoord> PrecomputedPathTo(AxialCoord from, AxialCoord to) { return(_precomputedPaths[CoordPair.Build(from, to)]); }
protected bool Equals(CoordPair other) { return(CoordId == other.CoordId && StateId == other.StateId && string.Equals(CoordCode, other.CoordCode) && string.Equals(StateCode, other.StateCode)); }