How do I transform value into screen coordinates

In summary, to determine the scale for converting values into screen coordinates, you will need to know the size of the screen or canvas and divide it by the range of values you want to map. The steps involved in transforming values into screen coordinates are determining the scale factor, calculating the difference between the minimum and maximum values, and using that scale factor to convert each data point. When handling negative values, you can either map them as negative coordinates or shift them to the positive range. It is also possible to use a logarithmic scale for converting values into screen coordinates, which can be useful for large or exponentially distributed data. When dealing with missing or invalid data, you can replace them with a placeholder value or use interpolation to estimate the missing values.
  • #1
tonytj
1
0
How do I transform my x, y values into screen coordinates system

All values is in pixels
In my coordinate system origo is located in (40,495)
The display area that I can use is from X=40 to x=750 and
from y=495 to y=55
When you go down in the coordinate system the y value is increasing and when
you go to the right
the x value is increasing.
The y-axis is showing time from 12:00 to 20:00 and the x-axis is distance
showing from 0 to 800

So I can have values like
[13:10, 190]
[13:40, 240]
[14:25, 390]
[15:10, 431]
[16:10, 554]
[17:10, 643]
[18:10, 740]

I just wonder if someone has a algoritm that I can use to transform my
values into this coordinate system.


//Tony
 
Mathematics news on Phys.org
  • #2
I assume you want a linear transformation (so that one part of the screen isn not "squeezed" or "stretched" more than another). You want x= 0 to correspond to screen coordinate, h= 40 and x= 800 to correspond to h= 750. A linear transformation is of the form h= Ax+ B. x=0, h= 40 tells you that 40= A(0)= B so B= 40. x= 800, h= 750 gives 750= 800A+ B= 800A+ 40. Solve that for A.

Similarly, in terms of "y" and vertical coordinates, you want v= Ay+ B. y= 12, at the bottom, corresponds to v= 495 so 495= 12A+ B. y= 20, at the top, corresponds to v= 55 so 55= 20A+ B. You can eliminate B from that by subtracting the two equations: 495- 55= 440= 8A. Solve that for A, the put that into either equation to solve for B.
 

FAQ: How do I transform value into screen coordinates

How do I determine the scale for converting values into screen coordinates?

To determine the scale for converting values into screen coordinates, you will need to know the size of the screen or canvas you are working with. Divide the total width or height by the range of values you want to map onto the screen. This will give you the scale factor to use in your conversion.

What are the steps involved in transforming values into screen coordinates?

The steps involved in transforming values into screen coordinates are:
1. Determine the scale factor
2. Calculate the difference between the minimum and maximum values of your data
3. For each data point, subtract the minimum value and multiply by the scale factor
4. The resulting value is the coordinate on the screen or canvas

How do I handle negative values when converting to screen coordinates?

If your data contains negative values, you can either map them onto the screen as negative coordinates or shift them to the positive range by adding the absolute value of the minimum value to all data points. The latter method is more commonly used in data visualization.

Can I use a logarithmic scale for transforming values into screen coordinates?

Yes, you can use a logarithmic scale for converting values into screen coordinates. This can be useful for data with a large range of values or when the data is exponentially distributed. To use a logarithmic scale, simply take the logarithm of each data point before applying the scale factor.

How do I handle missing or invalid data when converting to screen coordinates?

If your dataset contains missing or invalid data, you will need to decide how to handle them in the conversion process. One approach is to replace the missing or invalid values with a placeholder value (such as 0) and ignore them in the conversion. Another approach is to use interpolation to estimate the missing values based on neighboring data points.

Similar threads

Replies
7
Views
985
Replies
1
Views
723
Replies
1
Views
1K
Replies
4
Views
1K
Back
Top