public static Vector getVector(Converter c, Point point) { Vector startA = new Vector(c.LongitudeToX(point.longitude), c.LatitudeToY(point.latitude), 0); return(startA); }
public void addPolygons() { Point Start = new Point(); Start.longitude = c.XtoLongitude(Channel.Start.X); Start.latitude = c.YtoLatitude(Channel.Start.Y); //TODO double latitude = Start.latitude; double longitude = Start.longitude; double channelMeterKm = channelWidth; double latitudePlus1 = latitude + 1; double longitudePlus1 = longitude + 1; double distLat1 = Converter.Distance(longitude, latitude, longitude, latitudePlus1); double distLong1 = Converter.Distance(longitude, latitude, longitudePlus1, latitude); double corridorDiffInLat = channelMeterKm / distLat1; double corridorDiffInLong = channelMeterKm / distLong1; double channelLatitude = corridorDiffInLat / 2; double channelLongitude = corridorDiffInLong / 2; double longitudePlusChannel = longitude + channelLongitude; double latitudePlusChannel = latitude + channelLatitude; double channelx = c.LongitudeToX(longitudePlusChannel) - Channel.Start.X; double channely = c.LatitudeToY(latitudePlusChannel) - Channel.Start.Y; Vector channel = new Vector(channelx, channely, 0); Vector startEnd = new Vector(Channel.End.X, Channel.End.Y, 0) - new Vector(Channel.Start.X, Channel.Start.Y, 0); Vector startEndOrtho = Vector.Orthogonal(startEnd) * (-1); Vector startEndOrthoNormalized = (startEndOrtho / Vector.Abs(startEndOrtho)) * Vector.Abs(channel); Vector startEndNormalized = (startEnd / Vector.Abs(startEnd)) * Vector.Abs(channel); for (int i = 1; i < 8; i++) { Vector localChannel = Channel.LinearCombinations[i + 1] - Channel.LinearCombinations[i]; Vector localChannelOrtho = Vector.Orthogonal(localChannel); Vector localChannelOrthoNormalized = (localChannelOrtho / Vector.Abs(localChannelOrtho)) * -Vector.Abs(channel); Vector a1_intersection = Vector.InterceptionLine(Channel.LinearCombinations[i], startEndOrtho, Channel.LinearCombinations[i] + localChannelOrthoNormalized - localChannel * 10, Channel.LinearCombinations[i + 1] + localChannelOrthoNormalized + localChannel * 10); { Vector localChannel2 = Channel.LinearCombinations[i] - Channel.LinearCombinations[i - 1]; Vector localChannelOrtho2 = Vector.Orthogonal(localChannel2); Vector localChannelOrthoNormalized2 = (localChannelOrtho2 / Vector.Abs(localChannelOrtho2)) * -Vector.Abs(channel); Vector a1_intersection2 = Vector.InterceptionLine(Channel.LinearCombinations[i], startEndOrtho, Channel.LinearCombinations[i] + localChannelOrthoNormalized2 - localChannel2 * 10, Channel.LinearCombinations[i] + localChannelOrthoNormalized2 + localChannel2 * 10); a1_intersection = new Vector(a1_intersection.X, Math.Min(a1_intersection.Y, a1_intersection2.Y), 0); } Vector a2_intersection = Vector.InterceptionLine(Channel.LinearCombinations[i + 1], startEndOrtho, Channel.LinearCombinations[i] + localChannelOrthoNormalized - localChannel * 10, Channel.LinearCombinations[i + 1] + localChannelOrthoNormalized + localChannel * 10); { Vector localChannel2 = Channel.LinearCombinations[i + 2] - Channel.LinearCombinations[i + 1]; Vector localChannelOrtho2 = Vector.Orthogonal(localChannel2); Vector localChannelOrthoNormalized2 = (localChannelOrtho2 / Vector.Abs(localChannelOrtho2)) * -Vector.Abs(channel); Vector a2_intersection2 = Vector.InterceptionLine(Channel.LinearCombinations[i + 1], startEndOrtho, Channel.LinearCombinations[i + 1] + localChannelOrthoNormalized2 - localChannel2 * 10, Channel.LinearCombinations[i + 1] + localChannelOrthoNormalized2 + localChannel2 * 10); a2_intersection = new Vector(a2_intersection.X, Math.Min(a2_intersection.Y, a2_intersection2.Y), 0); } Vector a1 = a1_intersection; Vector a2 = a2_intersection; Vector a3 = a1 + startEndOrtho / 3; Vector a4 = a2 + startEndOrtho / 3; Polygons.Add(new ParcourPolygon(a1, a2, a4, a3)); Vector b1_intersection = Vector.InterceptionLine(Channel.LinearCombinations[i], startEndOrtho, Channel.LinearCombinations[i] - localChannelOrthoNormalized - localChannel * 10, Channel.LinearCombinations[i + 1] - localChannelOrthoNormalized + localChannel * 10); { Vector localChannel2 = Channel.LinearCombinations[i] - Channel.LinearCombinations[i - 1]; Vector localChannelOrtho2 = Vector.Orthogonal(localChannel2); Vector localChannelOrthoNormalized2 = (localChannelOrtho2 / Vector.Abs(localChannelOrtho2)) * -Vector.Abs(channel); Vector b1_intersection2 = Vector.InterceptionLine(Channel.LinearCombinations[i], startEndOrtho, Channel.LinearCombinations[i] - localChannelOrthoNormalized2 - localChannel2 * 10, Channel.LinearCombinations[i] - localChannelOrthoNormalized2 + localChannel2 * 10); b1_intersection = new Vector(b1_intersection.X, Math.Max(b1_intersection.Y, b1_intersection2.Y), 0); } Vector b2_intersection = Vector.InterceptionLine(Channel.LinearCombinations[i + 1], startEndOrtho, Channel.LinearCombinations[i] - localChannelOrthoNormalized - localChannel * 10, Channel.LinearCombinations[i + 1] - localChannelOrthoNormalized + localChannel * 10); { Vector localChannel2 = Channel.LinearCombinations[i + 2] - Channel.LinearCombinations[i + 1]; Vector localChannelOrtho2 = Vector.Orthogonal(localChannel2); Vector localChannelOrthoNormalized2 = (localChannelOrtho2 / Vector.Abs(localChannelOrtho2)) * -Vector.Abs(channel); Vector b2_intersection2 = Vector.InterceptionLine(Channel.LinearCombinations[i + 1], startEndOrtho, Channel.LinearCombinations[i + 1] - localChannelOrthoNormalized2 - localChannel2 * 10, Channel.LinearCombinations[i + 1] - localChannelOrthoNormalized2 + localChannel2 * 10); b2_intersection = new Vector(b2_intersection.X, Math.Max(b2_intersection.Y, b2_intersection2.Y), 0); } Vector b1 = b1_intersection; Vector b2 = b2_intersection; Vector b3 = b1 - startEndOrtho / 3; Vector b4 = b2 - startEndOrtho / 3; Polygons.Add(new ParcourPolygon(b1, b2, b4, b3)); } }
public static Vector getVector(Converter c, Point point) { return new Vector(c.LongitudeToX(point.longitude), c.LatitudeToY(point.latitude), 0); }
public static Vector getVector(Converter c, Point point) { return(new Vector(c.LongitudeToX(point.longitude), c.LatitudeToY(point.latitude), 0)); }
public void GenerateParcour(ParcourSet parcour, Converter c, double lenght, double channel, int count) { this.parcour = parcour; this.c = c; this.count = count; Line Start = parcour.Line.Single(p => p.Type == (int)LineType.START) as Line; if (Start == null) { return; } #region StartVektoren Vector StartAV = new Vector(c.LongitudeToX(Start.A.longitude), c.LatitudeToY(Start.A.latitude), 0); Vector StartBV = new Vector(c.LongitudeToX(Start.B.longitude), c.LatitudeToY(Start.B.latitude), 0); Vector StartOV = new Vector(c.LongitudeToX(Start.O.longitude), c.LatitudeToY(Start.O.latitude), 0); Vector StartAB = Vector.Direction(StartAV, StartBV); Vector StartMV = Vector.Middle(StartAV, StartBV); Vector StartLotOrientation = Vector.MinDistance(StartAV, StartBV, StartOV); double GateRadiusKm = Converter.NMtoM(0.3); Vector StartABNormalized = StartAB / Vector.Abs(StartAB); double StartABLength = Converter.Distance(c.XtoLongitude(StartAV.X), c.YtoLatitude(StartAV.Y), c.XtoLongitude((StartAV + StartABNormalized).X), c.YtoLatitude((StartAV + StartABNormalized).Y)); Vector StartAB1KM = StartABNormalized / StartABLength; StartLotOrientation = StartLotOrientation * (Vector.Abs(StartAB1KM * GateRadiusKm) / Vector.Abs(StartLotOrientation)); StartOV = StartMV + (StartLotOrientation * 2); Vector Start_A_M = StartAV + (StartAB1KM * GateRadiusKm); Vector Start_A_A = StartAV; Vector Start_A_B = Start_A_M + (StartAB1KM * GateRadiusKm); Vector Start_A_O = Start_A_M + StartLotOrientation; Line Start_A; if (parcour.Line.Any(p => p.Type == (int)LineType.START_A)) { Start_A = parcour.Line.Single(p => p.Type == (int)LineType.START_A); } else { Start_A = new Line(); Start_A.Type = (int)LineType.START_A; parcour.Line.Add(Start_A); } Start_A.A = Factory.newGPSPoint(c.XtoLongitude(Start_A_A.X), c.YtoLatitude(Start_A_A.Y), 0); Start_A.B = Factory.newGPSPoint(c.XtoLongitude(Start_A_B.X), c.YtoLatitude(Start_A_B.Y), 0); Start_A.O = Factory.newGPSPoint(c.XtoLongitude(Start_A_O.X), c.YtoLatitude(Start_A_O.Y), 0); Vector Start_D_M = StartBV - (StartAB1KM * GateRadiusKm); Vector Start_D_B = StartBV; Vector Start_D_A = Start_D_M - (StartAB1KM * GateRadiusKm); Vector Start_D_O = Start_D_M + StartLotOrientation; Line Start_D; if (parcour.Line.Any(p => p.Type == (int)LineType.START_D)) { Start_D = parcour.Line.Single(p => p.Type == (int)LineType.START_D); } else { Start_D = new Line(); Start_D.Type = (int)LineType.START_D; parcour.Line.Add(Start_D); } Start_D.A = Factory.newGPSPoint(c.XtoLongitude(Start_D_A.X), c.YtoLatitude(Start_D_A.Y), 0); Start_D.B = Factory.newGPSPoint(c.XtoLongitude(Start_D_B.X), c.YtoLatitude(Start_D_B.Y), 0); Start_D.O = Factory.newGPSPoint(c.XtoLongitude(Start_D_O.X), c.YtoLatitude(Start_D_O.Y), 0); Vector Start_B_M = Start_A_M + (Vector.Direction(Start_A_M, Start_D_M) / 3.0); Vector Start_B_A = Start_B_M - (StartAB1KM * GateRadiusKm); Vector Start_B_B = Start_B_M + (StartAB1KM * GateRadiusKm); Vector Start_B_O = Start_B_M + StartLotOrientation; Line Start_B; if (parcour.Line.Any(p => p.Type == (int)LineType.START_B)) { Start_B = parcour.Line.Single(p => p.Type == (int)LineType.START_B); } else { Start_B = new Line(); Start_B.Type = (int)LineType.START_B; parcour.Line.Add(Start_B); } Start_B.A = Factory.newGPSPoint(c.XtoLongitude(Start_B_A.X), c.YtoLatitude(Start_B_A.Y), 0); Start_B.B = Factory.newGPSPoint(c.XtoLongitude(Start_B_B.X), c.YtoLatitude(Start_B_B.Y), 0); Start_B.O = Factory.newGPSPoint(c.XtoLongitude(Start_B_O.X), c.YtoLatitude(Start_B_O.Y), 0); Vector Start_C_M = Start_A_M + ((Vector.Direction(Start_A_M, Start_D_M) * 2) / 3.0); Vector Start_C_B = Start_C_M - (StartAB1KM * GateRadiusKm); Vector Start_C_A = Start_C_M + (StartAB1KM * GateRadiusKm); Vector Start_C_O = Start_C_M + StartLotOrientation; Line Start_C; if (parcour.Line.Any(p => p.Type == (int)LineType.START_C)) { Start_C = parcour.Line.Single(p => p.Type == (int)LineType.START_C); } else { Start_C = new Line(); Start_C.Type = (int)LineType.START_C; parcour.Line.Add(Start_C); } Start_C.A = Factory.newGPSPoint(c.XtoLongitude(Start_C_A.X), c.YtoLatitude(Start_C_A.Y), 0); Start_C.B = Factory.newGPSPoint(c.XtoLongitude(Start_C_B.X), c.YtoLatitude(Start_C_B.Y), 0); Start_C.O = Factory.newGPSPoint(c.XtoLongitude(Start_C_O.X), c.YtoLatitude(Start_C_O.Y), 0); #endregion #region EndeVektoren double lengthKm = Converter.NMtoM(lenght); Vector lotPoint = StartMV + StartLotOrientation; double lotLenght = Converter.Distance(c.XtoLongitude(StartMV.X), c.YtoLatitude(StartMV.Y), c.XtoLongitude(lotPoint.X), c.YtoLatitude(lotPoint.Y)); Vector StartEnd = (StartLotOrientation / lotLenght) * lengthKm * EndLineDist; //Shorten to make linearcombinations of vectors ... factor to be definded Vector EndeAV = StartAV + StartEnd; Vector EndeBV = StartBV + StartEnd; Vector EndeMV = Vector.Middle(EndeAV, EndeBV); Vector EndeOV = EndeMV + StartLotOrientation; Vector EndeAB = Vector.Direction(EndeAV, EndeBV); Vector Ende_A_A = Start_A_A + StartEnd; Vector Ende_A_B = Start_A_B + StartEnd; Vector Ende_A_M = Start_A_M + StartEnd; Vector Ende_A_O = Start_A_O + StartEnd; Line END_A; if (parcour.Line.Any(p => p.Type == (int)LineType.END_A)) { END_A = parcour.Line.Single(p => p.Type == (int)LineType.END_A); } else { END_A = new Line(); END_A.Type = (int)LineType.END_A; parcour.Line.Add(END_A); } END_A.A = Factory.newGPSPoint(c.XtoLongitude(Ende_A_A.X), c.YtoLatitude(Ende_A_A.Y), 0); END_A.B = Factory.newGPSPoint(c.XtoLongitude(Ende_A_B.X), c.YtoLatitude(Ende_A_B.Y), 0); END_A.O = Factory.newGPSPoint(c.XtoLongitude(Ende_A_O.X), c.YtoLatitude(Ende_A_O.Y), 0); Vector Ende_B_A = Start_B_A + StartEnd; Vector Ende_B_B = Start_B_B + StartEnd; Vector Ende_B_M = Start_B_M + StartEnd; Vector Ende_B_O = Start_B_O + StartEnd; Line END_B; if (parcour.Line.Any(p => p.Type == (int)LineType.END_B)) { END_B = parcour.Line.Single(p => p.Type == (int)LineType.END_B); } else { END_B = new Line(); END_B.Type = (int)LineType.END_B; parcour.Line.Add(END_B); } END_B.A = Factory.newGPSPoint(c.XtoLongitude(Ende_B_A.X), c.YtoLatitude(Ende_B_A.Y), 0); END_B.B = Factory.newGPSPoint(c.XtoLongitude(Ende_B_B.X), c.YtoLatitude(Ende_B_B.Y), 0); END_B.O = Factory.newGPSPoint(c.XtoLongitude(Ende_B_O.X), c.YtoLatitude(Ende_B_O.Y), 0); Vector Ende_C_A = Start_C_A + StartEnd; Vector Ende_C_B = Start_C_B + StartEnd; Vector Ende_C_M = Start_C_M + StartEnd; Vector Ende_C_O = Start_C_O + StartEnd; Line END_C; if (parcour.Line.Any(p => p.Type == (int)LineType.END_C)) { END_C = parcour.Line.Single(p => p.Type == (int)LineType.END_C); } else { END_C = new Line(); END_C.Type = (int)LineType.END_C; parcour.Line.Add(END_C); } END_C.A = Factory.newGPSPoint(c.XtoLongitude(Ende_C_A.X), c.YtoLatitude(Ende_C_A.Y), 0); END_C.B = Factory.newGPSPoint(c.XtoLongitude(Ende_C_B.X), c.YtoLatitude(Ende_C_B.Y), 0); END_C.O = Factory.newGPSPoint(c.XtoLongitude(Ende_C_O.X), c.YtoLatitude(Ende_C_O.Y), 0); Vector Ende_D_A = Start_D_A + StartEnd; Vector Ende_D_B = Start_D_B + StartEnd; Vector Ende_D_M = Start_D_M + StartEnd; Vector Ende_D_O = Start_D_O + StartEnd; Line END_D; if (parcour.Line.Any(p => p.Type == (int)LineType.END_D)) { END_D = parcour.Line.Single(p => p.Type == (int)LineType.END_D); } else { END_D = new Line(); END_D.Type = (int)LineType.END_D; parcour.Line.Add(END_D); } END_D.A = Factory.newGPSPoint(c.XtoLongitude(Ende_D_A.X), c.YtoLatitude(Ende_D_A.Y), 0); END_D.B = Factory.newGPSPoint(c.XtoLongitude(Ende_D_B.X), c.YtoLatitude(Ende_D_B.Y), 0); END_D.O = Factory.newGPSPoint(c.XtoLongitude(Ende_D_O.X), c.YtoLatitude(Ende_D_O.Y), 0); #endregion #region LineOfNoReturn double lengthLONRKm = Converter.NMtoM(LineOfNoReturnDist); Vector StartToLONR = (StartLotOrientation / lotLenght) * ((lengthKm * EndLineDist) - lengthLONRKm); Vector LONR_A = StartAV + StartToLONR; Vector LONR_B = StartBV + StartToLONR; Vector LONR_O = StartOV + StartToLONR; Line LONR; if (parcour.Line.Any(p => p.Type == (int)LineType.NOBACKTRACKLINE)) { LONR = parcour.Line.Single(p => p.Type == (int)LineType.NOBACKTRACKLINE); } else { LONR = new Line(); LONR.Type = (int)LineType.NOBACKTRACKLINE; parcour.Line.Add(LONR); } LONR.A = Factory.newGPSPoint(c.XtoLongitude(LONR_A.X), c.YtoLatitude(LONR_A.Y), 0); LONR.B = Factory.newGPSPoint(c.XtoLongitude(LONR_B.X), c.YtoLatitude(LONR_B.Y), 0); LONR.O = Factory.newGPSPoint(c.XtoLongitude(LONR_O.X), c.YtoLatitude(LONR_O.Y), 0); #endregion CalculateParcour(parcour, c, channel); }