mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Fix WinUI/UWP Matrix
This commit is contained in:
parent
448177418e
commit
c404fd2a90
|
|
@ -72,7 +72,7 @@ namespace MapControl
|
||||||
public void SetTransform(Point mapCenter, Point viewCenter, double scale, double rotation)
|
public void SetTransform(Point mapCenter, Point viewCenter, double scale, double rotation)
|
||||||
{
|
{
|
||||||
Scale = scale;
|
Scale = scale;
|
||||||
Rotation = rotation;
|
Rotation = ((rotation % 360d) + 360d) % 360d;
|
||||||
|
|
||||||
var transform = new Matrix(Scale, 0d, 0d, -Scale, -Scale * mapCenter.X, Scale * mapCenter.Y);
|
var transform = new Matrix(Scale, 0d, 0d, -Scale, -Scale * mapCenter.X, Scale * mapCenter.Y);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// © 2022 Clemens Fischer
|
// © 2022 Clemens Fischer
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
// Licensed under the Microsoft Public License (Ms-PL)
|
||||||
|
|
||||||
|
using ABI.Microsoft.UI.Xaml.Media;
|
||||||
using System;
|
using System;
|
||||||
#if WINUI
|
#if WINUI
|
||||||
using XamlMedia = Microsoft.UI.Xaml.Media;
|
using XamlMedia = Microsoft.UI.Xaml.Media;
|
||||||
|
|
@ -40,7 +41,7 @@ namespace MapControl
|
||||||
|
|
||||||
public Point Transform(Point p)
|
public Point Transform(Point p)
|
||||||
{
|
{
|
||||||
return new Point(M11 * p.X + M12 * p.Y + OffsetX, M21 * p.X + M22 * p.Y + OffsetY);
|
return new Point(M11 * p.X + M21 * p.Y + OffsetX, M12 * p.X + M22 * p.Y + OffsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Translate(double x, double y)
|
public void Translate(double x, double y)
|
||||||
|
|
@ -58,6 +59,8 @@ namespace MapControl
|
||||||
var cos = Math.Cos(angle);
|
var cos = Math.Cos(angle);
|
||||||
var sin = Math.Sin(angle);
|
var sin = Math.Sin(angle);
|
||||||
|
|
||||||
|
// Multiply(new Matrix(cos, sin, -sin, cos, 0d, 0d));
|
||||||
|
|
||||||
SetMatrix(
|
SetMatrix(
|
||||||
cos * M11 - sin * M12,
|
cos * M11 - sin * M12,
|
||||||
sin * M11 + cos * M12,
|
sin * M11 + cos * M12,
|
||||||
|
|
@ -83,6 +86,17 @@ namespace MapControl
|
||||||
invDet * (M12 * OffsetX - M11 * OffsetY));
|
invDet * (M12 * OffsetX - M11 * OffsetY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Multiply(Matrix m)
|
||||||
|
{
|
||||||
|
SetMatrix(
|
||||||
|
M11 * m.M11 + M12 * m.M21,
|
||||||
|
M11 * m.M12 + M12 * m.M22,
|
||||||
|
M21 * m.M11 + M22 * m.M21,
|
||||||
|
M21 * m.M12 + M22 * m.M22,
|
||||||
|
OffsetX * m.M11 + OffsetY * m.M21 + m.OffsetX,
|
||||||
|
OffsetX * m.M12 + OffsetY * m.M22 + m.OffsetY);
|
||||||
|
}
|
||||||
|
|
||||||
private void SetMatrix(double m11, double m12, double m21, double m22, double offsetX, double offsetY)
|
private void SetMatrix(double m11, double m12, double m21, double m22, double offsetX, double offsetY)
|
||||||
{
|
{
|
||||||
M11 = m11;
|
M11 = m11;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue