-
October 11th, 2013, 12:13 PM
#1
MFC's Coordinate System?
Hello,
I am drawing in a simple (square) MFC window. I realize that (0,0) starts in the upper left hand corner. I wanted to see how MFC handled drawing of angles, so I use this code:
Code:
double CompassDegreesToRadians(double compassDegrees)
{
return((PI / 2.0f) - (compassDegrees * PI / 180.0f));
}
// Make pen
CPen penRed;
penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));
// Test Angles
CRect rectClient;
GetClientRect(rectClient);
float angle1 = 0;
int radius = rectClient.CenterPoint().x;
int x1 = radius * cos(CompassDegreesToRadians(angle1));
int y1 = radius * sin(CompassDegreesToRadians(angle1));
dc.MoveTo(rectClient.CenterPoint());
dc.LineTo(x1, y1);
Using this code, and changing the value of angle1 to these values (0, 90, 180, 270) I think MFC uses the coordinate system:
Code:
180 -y
|
|
-x 270---------------- 90 +x
|
|
0 +y
This seems like a strange coordinate system to use. Am I doing something wrong? If this is correct, how can I convert my calculations to this coordinate system? (compass degrees):
Code:
0 +y
|
|
-x 270---------------- 90 +x
|
|
180 -y
Last edited by clow; October 11th, 2013 at 04:38 PM.
-
October 11th, 2013, 04:15 PM
#2
Re: MFC's Coordinate System?
If you do not like this coordinate system, change your mapping mode from MM_TEXT to something like MM_HIMETRIC (or MM_HIENGLISH).
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
October 11th, 2013, 04:37 PM
#3
Re: MFC's Coordinate System?
Hello,
Yeah I saw those functions, and tried MM_LOENGLISH, but when I did that, nothing appeared on the screen. How would I calculate the coordinate system transform by normal C++ code between the two systems I listed above?
Thanks!
-
October 11th, 2013, 04:37 PM
#4
Re: MFC's Coordinate System?
Or just have resultant y1 coordinate multiplied by -1.
Best regards,
Igor
-
October 11th, 2013, 04:54 PM
#5
Re: MFC's Coordinate System?
Originally Posted by clow
...tried MM_LOENGLISH, but when I did that, nothing appeared on the screen.
With those mapping modes, your (0,0) point is in the LOWER-LEFT corner of the window, X grows to the right and Y - up.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|