/// <summary> /// This method is used to check if the ladder is intersecting with the snake. /// </summary> /// <param name="iSnake">The snake with which the intersection is to be checked.</param> /// <returns>True if intersecting else false.</returns> public bool IsIntersecting(Snake iSnake) { Vector L1Start = new Vector(Line1.X1, Line1.Y1); Vector L1End = new Vector(Line1.X2, Line1.Y2); Vector L2Start = new Vector(Line2.X1, Line2.Y1); Vector L2End = new Vector(Line2.X2, Line2.Y2); Vector L3Start = new Vector(firstStep.X1, firstStep.Y1); Vector L3End = new Vector(firstStep.X2, firstStep.Y2); Vector L4Start = new Vector(lastStep.X1, lastStep.Y1); Vector L4End = new Vector(lastStep.X2, lastStep.Y2); Line[] iSnakeLines = iSnake.GetLines(); Vector iL1Start = new Vector(iSnakeLines[0].X1, iSnakeLines[0].Y1); Vector iL1End = new Vector(iSnakeLines[0].X2, iSnakeLines[0].Y2); Vector iL2Start = new Vector(iSnakeLines[1].X1, iSnakeLines[1].Y1); Vector iL2End = new Vector(iSnakeLines[1].X2, iSnakeLines[1].Y2); Vector intersectionPoint = new Vector(); return(SnLUtility.LineSegementsIntersect(iL1Start, iL1End, L1Start, L1End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL1Start, iL1End, L2Start, L2End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L1Start, L1End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L2Start, L2End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L3Start, L3End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L4Start, L4End, out intersectionPoint, true) ); }
/// <summary> /// This method is used to check if the snake is intersecting with the ladder or not. /// </summary> /// <param name="iLadder">The ladder with which intersection is to be checked.</param> /// <returns>True if there is intersection else false.</returns> public bool IsIntersecting(Ladder iLadder) { Line[] snakeLines = GetLines(); Line[] iLadderLines = iLadder.GetLines(); Vector L1Start = new Vector(snakeLines[0].X1, snakeLines[0].Y1); Vector L1End = new Vector(snakeLines[0].X2, snakeLines[0].Y2); Vector L2Start = new Vector(snakeLines[1].X1, snakeLines[1].Y1); Vector L2End = new Vector(snakeLines[1].X2, snakeLines[1].Y2); Vector L3Start = new Vector(snakeLines[2].X1, snakeLines[2].Y1); Vector L3End = new Vector(snakeLines[2].X2, snakeLines[2].Y2); Vector L4Start = new Vector(snakeLines[3].X1, snakeLines[3].Y1); Vector L4End = new Vector(snakeLines[3].X2, snakeLines[3].Y2); Vector iL1Start = new Vector(iLadderLines[0].X1, iLadderLines[0].Y1); Vector iL1End = new Vector(iLadderLines[0].X2, iLadderLines[0].Y2); Vector iL2Start = new Vector(iLadderLines[1].X1, iLadderLines[1].Y1); Vector iL2End = new Vector(iLadderLines[1].X2, iLadderLines[1].Y2); Vector intersectionPoint = new Vector(); return(SnLUtility.LineSegementsIntersect(iL1Start, iL1End, L1Start, L1End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL1Start, iL1End, L2Start, L2End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L1Start, L1End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L2Start, L2End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L3Start, L3End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L4Start, L4End, out intersectionPoint, true) ); }
/// <summary> /// This method is used to check the intersection of the ladders. /// </summary> /// <param name="iLadder">The ladder with which intersection is to be checked.</param> /// <returns>True if interseting else false.</returns> public bool IsIntersecting(Ladder iLadder) { Vector L1Start = new Vector(Line1.X1, Line1.Y1); Vector L1End = new Vector(Line1.X2, Line1.Y2); Vector L2Start = new Vector(Line2.X1, Line2.Y1); Vector L2End = new Vector(Line2.X2, Line2.Y2); Vector L3Start = new Vector(firstStep.X1, firstStep.Y1); Vector L3End = new Vector(firstStep.X2, firstStep.Y2); Vector L4Start = new Vector(lastStep.X1, lastStep.Y1); Vector L4End = new Vector(lastStep.X2, lastStep.Y2); Vector iL1Start = new Vector(iLadder.Line1.X1, iLadder.Line1.Y1); Vector iL1End = new Vector(iLadder.Line1.X2, iLadder.Line1.Y2); Vector iL2Start = new Vector(iLadder.Line2.X1, iLadder.Line2.Y1); Vector iL2End = new Vector(iLadder.Line2.X2, iLadder.Line2.Y2); Vector intersectionPoint = new Vector(); return(SnLUtility.LineSegementsIntersect(iL1Start, iL1End, L1Start, L1End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL1Start, iL1End, L2Start, L2End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L1Start, L1End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L2Start, L2End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L3Start, L3End, out intersectionPoint, true) || SnLUtility.LineSegementsIntersect(iL2Start, iL2End, L4Start, L4End, out intersectionPoint, true) ); }