199k views
4 votes
Suppose you have created a canvas with coordinates (0,0) to (100,100). A mouse click returns window coordinates (25,25). What are the corresponding clip coordinates? Make a sketch.

User Ageis
by
6.9k points

1 Answer

3 votes

Final answer:

To convert window coordinates (25,25) on a canvas from (0,0) to (100,100) to clip coordinates, we use a linear mapping resulting in clip coordinates (-0.5, -0.5).

Step-by-step explanation:

The question involves converting window coordinates to clip coordinates on a canvas that ranges from (0,0) to (100,100). When we receive window coordinates, they are specific to the window system's screen space. On the other hand, clip coordinates are a normalized form usually ranging from -1 to 1 in both x and y directions, used in graphics pipelines like OpenGL.

In this case, to convert window coordinates (25,25) to clip coordinates, we assume a linear mapping from the window space to clip space. Generally, to convert a point (x,y) in window coordinates to clip coordinates (x', y') we use the equations:

Applying this to our window coordinates of (25,25):

Therefore, the corresponding clip coordinates would be (-0.5, -0.5).

If we were to sketch this, you would draw a square representing the canvas and mark the point (25,25). Then, on a normalized square representing clip space, mark the point (-0.5,-0.5).

User Steeve
by
7.9k points