public void AangrenzendeStratenReport(int straatId) { List <Straat> straten = Fetch.ReturnStratenAangrenzendAanId(straatId); Straat origineleStraat = Fetch.ReturnStraatVoorId(straatId); string exitPath = Path.Combine(ReportsPath, $"Aangrenzende straten van {origineleStraat.Naam}, {origineleStraat.Gemeente.Naam}.txt"); CheckAndDeleteFile(exitPath); using (StreamWriter writer = File.CreateText(exitPath)) { writer.WriteLine($"Aantal aangrenzende straten: {straten.Count} \n"); foreach (Straat str in straten) { List <Segment> segmenten = str.Graaf.GetSegmenten(); writer.WriteLine($"{str.StraatID}, {str.Naam}, {str.Gemeente.Naam}, {str.Gemeente.Provincie.Naam}"); writer.WriteLine($"aantal knopen: {str.Graaf.getKnopen().Count}"); writer.WriteLine($"aantal wegsegmenten: {segmenten.Count}"); foreach (KeyValuePair <Knoop, List <Segment> > pair in str.Graaf.Map) { Punt temp = pair.Key.SegmentPunt; writer.WriteLine($"Knoop[{pair.Key.KnoopID},[{temp.X};{temp.Y}]]"); foreach (Segment seg in pair.Value) { writer.WriteLine($" [segment:{seg.SegmentID},begin:{seg.BeginKnoop.KnoopID},eind:{seg.EindKnoop.KnoopID}]"); foreach (Punt punt in seg.Vertices) { writer.WriteLine($" ({punt.X};{punt.Y})"); } } } } } Console.WriteLine($"Aangrenzende straten Report weggeschreven in {exitPath}\n\n"); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Leerling,Klas,Min,Max")] Punt punt) { if (id != punt.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(punt); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PuntExists(punt.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(punt)); }
public static float DistanceFromPlane(Punt O, Punt N, Punt p) { //http://mathworld.wolfram.com/Plane.html //http://mathworld.wolfram.com/Point-PlaneDistance.html //maakt vector van O naar p, projecteert deze op N en geeft zijn lengte terug float D = (N.X * p.X + N.Y * p.Y + N.Z * p.Z - N.X * O.X - N.Y * O.Y - N.Z * O.Z) / N.Length; return(D); }
public async Task <IActionResult> Create([Bind("Id,Leerling,Klas,Min,Max")] Punt punt) { if (ModelState.IsValid) { _context.Add(punt); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(punt)); }
// part of the implemetation that takes care of filling the box public void FillBox() { // punt K points on the plane and fills the rest of the box uniformly //first, we create 'amountOfPlanePoints' on the plane and put them in pointList pointList = new Punt[amountOfPoints]; CreatePlanePoints(); // The pointList array is now filled up untill 'amountOfPlanePoints'. // Now, we need to randomize these with the RandomizePoints() method. RandomizePlanePoints(); // When this is done, create a new array of points size 'amountOfPoints', fill it with the randomized plane points // And then add 'amountofPoints - amountOfPlanePoints' extra points. CreateBoxPoints(); }
private Punt ShiftPointWithinBall(Punt p, int BallRadius) { //shifts a point within a ball of a certain radius double X1, X2, X3, U; X1 = r.NextDouble(); X2 = r.NextDouble(); X3 = r.NextDouble(); U = r.NextDouble(); float D = ballRadius * (float)Math.Pow(U, ((double)1 / (double)3)); double v = D / Math.Sqrt(Math.Pow(X1, 2) + Math.Pow(X2, 2) + Math.Pow(X3, 2)); return(new Punt((float)(v * X1), (float)(v * X2), (float)(v * X3))); }
private void CreatePoints(int x1, int x2, int y1, int y2, int z1, int z2, int endIndex, int startIndex = 0) { //creates the uniform random point between the given x,y,z-values int newX, newY, newZ; for (int i = startIndex; i < endIndex; i++) { newX = r.Next(x1, x2 + 1); newY = r.Next(y1, y2 + 1); if (z1 != z2) { newZ = r.Next(z1, z2 + 1); } else { newZ = z1; } pointList[i] = new Punt(newX, newY, newZ); } }
private static Punt GetPuntByKnoopId(int knoopid, SqlConnection openConnection) { var sql3 = "SELECT p.X,p.Y " + "FROM punt p JOIN Knoop k " + "ON(k.PuntId = p.Id) " + "WHERE k.Id = @KnoopId;"; SqlCommand cmd3 = new SqlCommand(sql3, openConnection); cmd3.Parameters.AddWithValue("@KnoopId", knoopid); using (SqlDataReader reader = cmd3.ExecuteReader()) { var punt = new Punt(); if (reader.Read()) { punt.X = Convert.ToInt32(reader[0]); punt.Y = Convert.ToInt32(reader[1]); } return(punt); } }
//static private string _connString = @"Data Source=LAPTOP-DPRRU9CI\SQLEXPRESS1;Initial Catalog=TestStratenSegmenten;Integrated Security=True"; #region Privates private static int ExportPunt(Punt p) { string sql = "INSERT INTO Punt(X,Y) " + "VALUES (@X, @Y);" + "SELECT SCOPE_IDENTITY()"; int id = -1; using (SqlConnection conn = new SqlConnection(_connString)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.Add("@X", SqlDbType.Float); cmd.Parameters.Add("@Y", SqlDbType.Float); cmd.Parameters["@X"].Value = p.X; cmd.Parameters["@Y"].Value = p.Y; id = Convert.ToInt32(cmd.ExecuteScalar()); } return(id); }
private int FindPointsForSomePlane() { //maakt een plane uit random punten en geeft terug hoeveel punten er in de box langs de plane liggen //vind 3 verschillende random punten die straks een plane vormen int a, b, c; a = r.Next(amountOfPoints); b = r.Next(amountOfPoints); c = r.Next(amountOfPoints); while (b == a) { b = r.Next(amountOfPoints); } while (c == a || a == b) { c = r.Next(amountOfPoints); } //plane gaat door a en heeft normaalvector N = (b-a)X(c-a) Punt N = pointList[b].Substract(pointList[a]).Cross(pointList[c].Substract(pointList[a])); //kijkt voor alle punten... int L = 0; for (int i = 0; i < pointList.Length; i++) { //..of ze dicht genoeg bij de gevormde plane liggen float D = Punt.DistanceFromPlane(pointList[a], N, pointList[i]); if (Math.Abs(D) <= planeDistance) { L++; } } //geeft het aantal punten terug dat bij de plane ligt return(L); }
private static List <Punt> GetAllPointsOfSegment(Segment s, SqlConnection openConnection) { var sql = "SELECT p.X, p.Y " + "FROM Punt p JOIN SegmentId_PuntId sp " + "ON(p.Id = sp.PuntId) " + "WHERE sp.SegmentId = @segmentId " + "ORDER BY p.Id"; SqlCommand cmd = new SqlCommand(sql, openConnection); cmd.Parameters.AddWithValue("@segmentId", s.Id); using (SqlDataReader reader = cmd.ExecuteReader()) { var punten = new List <Punt>(); while (reader.Read()) { var punt = new Punt(); punt.X = Convert.ToInt32(reader[0]); punt.Y = Convert.ToInt32(reader[1]); punten.Add(punt); } return(punten); } }
public float Dot(Punt p) { return(this.X * p.X + this.Y * p.Y + this.Z * p.Z); }
public Punt Cross(Punt p) { return(new Punt(this.Y * p.Z - this.Z * p.Y, this.Z * p.X - this.X * p.Z, this.X * p.Y - this.Y * p.X)); }
public Punt Substract(Punt punt) { return(new Punt(this.X - punt.X, this.Y - punt.Y, this.Z - punt.Z)); }
public Punt Add(Punt punt) { return(new Punt(punt.X + this.X, punt.Y + this.Y, punt.Z + this.Z)); }
//Console.WriteLine("testen"); //Belgie belg = TestData(); ////Knoop knoop1 = new Knoop(30, new Punt(2.45, 3.45)); ////dp.FillDataBase(); //} static Belgie TestData() { Punt testPunt1 = new Punt(2.45, 3.45); Punt testPunt2 = new Punt(3.45, 4.45); Punt testPunt3 = new Punt(4.45, 5.45); Punt testPunt4 = new Punt(5.45, 6.45); Punt testPunt5 = new Punt(6.45, 7.45); Knoop knoop1 = new Knoop(30, testPunt1); Knoop knoop2 = new Knoop(40, testPunt2); Knoop knoop3 = knoop1; Knoop knoop4 = new Knoop(50, testPunt3); List <Punt> puntlijstSeg1 = new List <Punt> { testPunt4 }; List <Punt> puntlijstSeg2 = new List <Punt> { testPunt5 }; Segment testSegment1 = new Segment(112, knoop1, knoop2, puntlijstSeg1); Segment testSegment2 = new Segment(113, knoop3, knoop4, puntlijstSeg2); Dictionary <Knoop, List <Segment> > testMap1 = new Dictionary <Knoop, List <Segment> >(); testMap1.Add(knoop1, new List <Segment> { testSegment1 }); testMap1.Add(knoop2, new List <Segment> { testSegment1 }); Dictionary <Knoop, List <Segment> > testMap2 = new Dictionary <Knoop, List <Segment> >(); testMap2.Add(knoop1, new List <Segment> { testSegment2 }); testMap2.Add(knoop2, new List <Segment> { testSegment2 }); Graaf testGraaf1 = new Graaf(250, testMap1); Graaf testGraaf2 = new Graaf(260, testMap2); Gemeente testGemeente = new Gemeente(12, "testGemeente"); Straat testStraat1 = new Straat(10, "TestStraat1", testGraaf1, testGemeente); Straat testStraat2 = new Straat(20, "TestStraat2", testGraaf2, testGemeente); Provincie testProvincie = new Provincie(1, "testProvincie"); testProvincie.VoegGemeenteToe(testGemeente); Belgie belg = new Belgie(new List <Provincie>() { testProvincie }); DataProcessing dp = new DataProcessing(belg); dp.CompletelyFillDataBase(); return(belg); }
public bool IsGelijkAan(Punt punt) { return GetType() == punt.GetType(); }