dotnet / dotnet/dotnet-api-docs

System.Windows.Media.Media3D Matrix3D.Append(Matrix3D) method has wrong description

Open
#6,617 1 comment 0 reactions 0 assignees View on GitHub
area-WPF Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

After using System.Windows.Media.Media3D Matrix3D for a while, i had some confusion about the order of transformations, therefore I started to look up the documentation. While I have been using mainly the * -Operator and therefore my logic behaved as expected, I looked at .Append and .Prepend. Mathematically, subsequent affine transformations should be represented by a left-hand-multiplication of the "latest" transformation in a sequence. Usually when using the *-Operator I carry out the transformations this way which works fine. I also verified that the operator and the two methods work as expected (see C# interactive and Octave outputs below). This leads me to the conclusion that the description included in the page must be flawed:

'Matrices can be appended or prepended to other matrices. Appending matrix A to matrix B denotes a transformation by B and then by A: A(B(...)) '

'Prepending A to B denotes a transformation by A and then by B: B(A(...)) '

It should be the other way around if I am not completely overlooking something.

Outputs of a "verification":

C# Interactive:

using System.Windows.Media.Media3D;
>
> Matrix3D m1 = new Matrix3D();
> m1
[Identity]
> m1 = new Matrix3D(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
> m1
[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16]
> Matrix3D m2 = new Matrix3D(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);
> m2
[17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32]
> m1*m2
[250;260;270;280;618;644;670;696;986;1028;1070;1112;1354;1412;1470;1528]
> m2*m1
[538;612;686;760;650;740;830;920;762;868;974;1080;874;996;1118;1240]
> Matrix3D m1_orig = m1;
> m1_orig
[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16]
> m1.Append(m2);
> m1
[250;260;270;280;618;644;670;696;986;1028;1070;1112;1354;1412;1470;1528]
> m1_orig
[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16]
> m1.Prepend(m2);
> m1
[61188;63784;66380;68976;74020;77160;80300;83440;86852;90536;94220;97904;99684;103912;108140;112368]
> m1 = m1_orig
[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16]
> m1
[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16]
> m1.Prepend(m2)
> m1
[538;612;686;760;650;740;830;920;762;868;974;1080;874;996;1118;1240]

Octave:
>> A = [1 1; 0 1]
A =

1 1
0 1

>> B = [1 2; 3 4]
B =

1 2
3 4

>> A*B
ans =

4 6
3 4

>> B*A
ans =

1 3
3 7
//A*B and B*A of the (2,2) matrices to verify operators are defined identically
>> m1 = [1,2,3,4;5,6,7,8;9 10 11 12;13 14 15 16]
m1 =

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

>> m2 = [17 18 19 20; 21 22 23 24; 25 26 27 28; 29 30 31 32]
m2 =

17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32

>> m1*m2
ans =

250 260 270 280
618 644 670 696
986 1028 1070 1112
1354 1412 1470 1528

>> m2*m1
ans =

538 612 686 760
650 740 830 920
762 868 974 1080
874 996 1118 1240

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.