Then you get a coordinate system that is stretched vertically and horizontally to the sides of the picturebox:
But if you manually enter the values from the transformation matrix then you only get a small coordinate system that is centered correctly but isnt scaled properly:
How come the transformation matrix's scale values are not higher then? (look at the other attached screen capture.
If you print the matrix elements you get when x-min/max and y-min/max are -3,3, -3,3 by:
If I instead enter the transformation Matrix by "hand" like this and of course make no other transformation before (remove the line: gr.Transform = new Matrix(rect, pts);):
gr.Transform = new Matrix((float)5.966666, 0, 0, (float)-3.583333, 179,107.5);
In theory this is correct as far as I understand, because what actually happens is that the coordinate transformation is done by (look at the bottom of the page http://msdn.microsoft.com/en-us/library/w8s1ct0z) )
multiplying the original coordinates by the transformation matrix (here just for the x-axis):
One can see that the pixel distance between the two coordinate sets are: 35,76. Then it is obvious why the coordinate system is so small.
My question is then: Why does the transformation matrix have scaling values that are so small and how does it stretch according to the first matrix constructor? This is very confusing. Its like the constructor adds something to stretch the rectangle to the border other than just the transformation matrix but I cant understand the theory and why.
If the scaling was greater in the transformation Matrix for example like this:
This would result in a larger coordinate system closer to the border of the picturebox:
I hope I have made myself clear and apologize if something is confusing.
Thanks a lot.
Regards
Hans
C#.NET ProgrammingVisual C++.NET
Last Comment
HansChr
8/22/2022 - Mon
Robert Schutt
The problem seems to be in your code to determine the elements. I use this code after setting gr.Transform:
First of all if I copy your code in Visual Studio I get the following error:
I don't know why it won't cast. I read somewhere that if you only have old versions of net installed this method doesnt work but I have up to Net 4.0 installed.
Apparently the code gets translated wrongly somehow.
If I change the min and max values of the axis to -3,3,-3,3 I get the correct look and the correct coordinates:
The float values at input is apparently interpreted wrongly. Instead of x-min being float -3.0, 3.0 as inputted from the textbox its gets set to -30, 30 and the same for the y.axis.
The author of the graph made a mistake in the property value of the textboxes containing the xmin/max ymin/max values:
He made the decimal with a dot "." but it should have been a comma ",". If you put a dot it just get ignored and 3.0 will be interpreted as 30.
Of course I didnt notice that because it is the "start"-up proporty of the graph. If I change the proporty of all the 4 textboxes to "," instead of "." I get the correct answer.
Oh my God. I used 2 weeks thinking about this and the problem was a dot instead of a comma. I love computers :-/....
I see your point. Its the same with Excel with respect to decimals:
In regional settings I changed the "decimal symbol" from "," to "." and now the original code works :
So it seems like a localized issue. Maybe changing to "British/american" doesnt change the "," to ".".
I didnt understand the last thing you wrote about being aware of the problem ;-).
Maybe the author could have made a case of "." and a case of "," to take the regional settings into account.
Robert Schutt
> I didnt understand the last thing you wrote about being aware of the problem ;-).
Oh, think nothing of it, I just meant it seemed from your post that you had already come across the problem of printing 5,96 for m11 and in the code adjusting the comma to a decimal point.
> Maybe the author could have made a case of "." and a case of "," to take the regional settings into account
Well yes, that's the big question for me, if it should be handled by Visual Studio maybe.
Well anyway thank you very much for your help ;-).
It seems like Visual Studio complains if I changed the decimal in regional settings from "," to "." and then changed the input to "3,0" but not the other way or something...
Open in new window
With the values this code returns (that differ from yours probably just because it's another Matrix) I can set it manually for the same size:Open in new window
Note that your code to print the elements uses 'ele' twice and actually prints the elements of the "Matrix inverse".