Screen Coordinates to Cartesian Coordinates

AI Thread Summary
To convert screen coordinates, which originate from the top left corner, to Cartesian coordinates, it's essential to understand that screen coordinates are already a form of Cartesian system. The main requirement is to adjust the origin and the direction of the positive y-axis. To achieve this, one must identify the center point of the screen and apply a translation to reposition it to the center of the Cartesian system. Additionally, a scaling factor is necessary to convert Cartesian coordinates to pixel values. The transformation equations are as follows: Xs = Xc + (X - Pcx) * S and Ys = Yc - (Y - Pcy) * S, where (X, Y) represents Cartesian coordinates, (Xs, Ys) are the corresponding screen coordinates, and Pcx and Pcy denote the center of the screen in Cartesian coordinates. This method allows for accurate mapping and can also facilitate inverse transformations for user interactions, such as mouse clicks.
computerex
Messages
68
Reaction score
0
Hello. Is there some easy way to convert screen coordinates (origin at the top left corner) to Cartesian coordinates?
 
Technology news on Phys.org
Sure: find the centre and translate...
 
I think I know what you mean, but I think asking for it shows a misunderstanding. Screen coordinates are a rectilinear 2 dimensional system, so they are already Cartesian. They just happen to be a Cartesian system with the origin at the upper left corner and the positive y-axis pointing down the screen.

What I think you want is a Cartesian system with the origin in a different location and probably a different direction for the positive y axis. If this is true, then cristo's answer is the way to go. You are simply transforming from one Cartesian system to a different one.

John
 
I have made an application where I need to display in Cartesian coordinates on the screen.
As Cristo said, you need to find the equivalent Cartesian coordintes of the centre point Pc. A translate willl bring Pc to the centre of the screen, and a scale will bring everything you want to see on the screen. You need to flip the sign of y so that y will go up instead.
Convert the centre of the screen in Carteesian coordinate to (Xc,Yc) in pixels, and S, scale to covert Cartesian to pixels. Usually, Xc and Yc are half of the screen size.
Xs=Xc+(X-Pcx)*S
Ys=Yc-(Y-Pcy)*S
where (X,Y) in Cartesian is mapped to (Xs,Ys) in screen coordinates, Pcx and Pcy are the centre of the screen in Cartesian coordinates, S is the scales factor from Cartesian to pixels.
You can calculte the inverse transformation if you pick things with the mouse.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top