scaling is nu gefixed, maar.. die colonies gaan ons altijd fucken

This commit is contained in:
BuildTools
2020-08-06 14:20:51 +02:00
parent 6fca4f27cc
commit 6f9f68a937
27 changed files with 34 additions and 22 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -34,9 +34,9 @@ namespace Globals
private void UpdateMaximumEnMinimum(PolygonPunten polygon)
{
if (polygon.MaximumX > MaximumX) MaximumX = polygon.MaximumX;
else if (polygon.MinimumX < MinimumX) MinimumX = polygon.MinimumX;
if (polygon.MinimumX < MinimumX) MinimumX = polygon.MinimumX;
if (polygon.MaximumY > MaximumY) MaximumY = polygon.MaximumY;
else if (polygon.MinimumY < MinimumY) MinimumY = polygon.MinimumY;
if (polygon.MinimumY < MinimumY) MinimumY = polygon.MinimumY;
}
public void UpdateMaximumEnMinimum()

View File

@@ -14,13 +14,22 @@ namespace Globals
{
Punten = punten;
Naam = naam;
MaximumX = Double.MinValue;
MaximumY = Double.MinValue;
MinimumX = Double.MaxValue;
MinimumY = Double.MaxValue;
UpdateMaxEnMinPunt();
}
public PolygonPunten(GeoJSON.Net.Geometry.Polygon polygon, string naam = "", bool reverse = true)
public PolygonPunten(Polygon polygon, string naam = "", bool reverse = true)
{
Naam = naam;
Punten = new List<Punt>();
MaximumX = Double.MinValue;
MaximumY = Double.MinValue;
MinimumX = Double.MaxValue;
MinimumY = Double.MaxValue;
foreach (LineString linestring in polygon.Coordinates)
{

View File

@@ -12,8 +12,8 @@ namespace Globals
Naam = naam;
if (Graden)
{
X = ConvertToPercentage(x) * 100;
Y = ConvertToPercentage(y) * 100;
X = ConvertToPercentage(x) * 50 + 50;
Y = ConvertToPercentage(y) * 50 + 50;
}
else
{
@@ -30,7 +30,7 @@ namespace Globals
public double ConvertToPercentage(double angle)
{
if (angle < 0) angle += 360;
return angle / 360;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -58,16 +58,16 @@ namespace Logica
return new PolygonPunten(returnWaarde, polygon.Naam);
}
//lat en long = graden, graden => coords (/360 * scale?
//scaling maakt nu gebruik van max en min waarden, dus als iets een punt was op 360 graden wordt het nu gezoomed
private static Punt ScalePoint(double scaleX, double scaleY, Punt punt, double maxX = 1, double maxY = 1, double offsetX = 0, double
offsetY = 0, double minX = 0, double minY = 0)
{
double x = punt.X;
x /= maxX;
double x = punt.X - minX;
x /= (maxX - minX);
x *= scaleX;
x += offsetX;
double y = punt.Y;
y /= maxY;
double y = punt.Y - minY;
y /= (maxY - minY);
y *= scaleY;
y += offsetY;
return new Punt(x, y, punt.Naam);
@@ -106,14 +106,19 @@ namespace Logica
return new MultiPolygonPunten(pp, multiPolygon.Naam);
}
//todo (offset var voor center op canvas, vree ambetant)
public List<MultiPolygonPunten> ScaleMultiPolygons(List<MultiPolygonPunten> multiPolygons, double scaleX, double scaleY, double offsetX = 0, double offsetY = 0)
{
//TODO onderdeel versnelen door manuele for each loop
double maxX = multiPolygons.Max(m => m.MaximumX);
double maxY = multiPolygons.Max(m => m.MaximumY);
double minX = multiPolygons.Min(m => m.MinimumX);
double minY = multiPolygons.Min(m => m.MinimumY);
double maxX = Double.MinValue;
double maxY = Double.MinValue;
double minX = Double.MaxValue;
double minY = Double.MaxValue;
foreach (MultiPolygonPunten mp in multiPolygons)
{
if (mp.MaximumX > maxX) maxX = mp.MaximumX;
if (mp.MinimumX < minX) minX = mp.MinimumX;
if (mp.MaximumY > maxY) maxY = mp.MaximumY;
if (mp.MinimumY < minY) minY = mp.MinimumY;
}
List<MultiPolygonPunten> mpps = new List<MultiPolygonPunten>();
foreach (MultiPolygonPunten mp in multiPolygons)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -108,13 +108,11 @@ namespace opdracht2
//voorbereiding van scale waarden.
double scaleX = (c.ActualHeight > c.ActualWidth) ? c.ActualWidth : c.ActualHeight;
double scaleY = (c.ActualHeight > c.ActualWidth) ? c.ActualWidth : c.ActualHeight;
scaleX /= 2;
scaleY /= 2;
double offsetX = scaleX; //vroeger c.ActualWidth/2
double offsetY = scaleY;
double offsetX = 0; //vroeger c.ActualWidth/2
double offsetY = 0;
//dit zorgt voor evenredige scaling zonder stretching. als men wel stretching wilt gebruiken:
// scaleX = c.ActualWidth;
// scaleY = c.ActualHeight;