Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在新对象上实现矩阵变换_C#_.net_Methods_Matrix_Graphicspath - Fatal编程技术网

C# 在新对象上实现矩阵变换

C# 在新对象上实现矩阵变换,c#,.net,methods,matrix,graphicspath,C#,.net,Methods,Matrix,Graphicspath,我需要能够转换我自己的一个对象以及.Net中的一些GraphicsPath对象。我需要在GraphicsPath对象上执行的任何缩放、平移和旋转操作也发生在我自己的对象上 例如,下面是一些缩放代码: using (Matrix ScaleTransform = new Matrix(1, 0, 0, 1, 0, 0)) // scale matrix { ScaleTransform.Scale(ScaleX, ScaleY); moPath.Transform(ScaleTra

我需要能够转换我自己的一个对象以及.Net中的一些GraphicsPath对象。我需要在GraphicsPath对象上执行的任何缩放、平移和旋转操作也发生在我自己的对象上

例如,下面是一些缩放代码:

using (Matrix ScaleTransform = new Matrix(1, 0, 0, 1, 0, 0)) // scale matrix
{
    ScaleTransform.Scale(ScaleX, ScaleY);
    moPath.Transform(ScaleTransform);
    moBoundingBox.Transform(ScaleTransform);

    MyObject.Transform(ScaleTranform);
}


//In "MyObject":
public void Transform(Matrix m)
{
    //How is this implemented?  Is there a built-in .Net method?
}
问题是: 在MyObject中实现“Transform”方法的最佳方法是什么。我做了相当多的搜索,但找不到任何最佳方法的参考


谢谢

自己实现转换并不困难,请看:

那么你的对象是位图还是什么?那么这可能是一种方式:

或者,您可以离开对象,将转换推到堆栈中,并在将其转换为图形时使用它

嘿-看起来Matrix类可以为您做很多事情:

比如说

TransformPoints(Point[]) or TransformVectors(Point[])

是的,GDI+(在.Net中)。System.Drawing和System.Drawing.Drawing2Hi-Rune,感谢您的回复。您给出的最后一个示例是我实际实现的示例。我只是将所有坐标转换成“点”,并将点数组传递到内置矩阵变换中。好主意+1并接受。