tag:blogger.com,1999:blog-6314876008291942531.post7331258411186934659..comments2021-03-28T11:31:00.109-07:00Comments on Antonio Gulli's coding playground: Fit a set of (x,y) data points to a rectangular displayUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6314876008291942531.post-84605977401693108972010-07-07T08:17:04.624-07:002010-07-07T08:17:04.624-07:00There are a few ways you can do this. Depends a lo...There are a few ways you can do this. Depends a lot upon what type of information you want preserved. <br /><br />Solution 1: Trivial one. Here compute new value of x to floor(S/N)*x for each x. Compute y to be floor(T/M)*y. However this solution does not take into account the input "spread". For example if your inputs for 'x' is largely less than or equal to S but have say only one at N, you would have "compressed" all x to accommodate this single occurrence.<br /><br />The following two solutions inspects the input to determine how the values of 'x' and 'y' are spread to determine what algorithm to use to make the mapping:<br /><br />Many values in the input are in the range 0<x<S and fewer in the S,x<N range:<br /><br />Solution 2: Use something similar to A-law or Mu-Law schemes used to represent speech in the audio world. Here values on the lower side tend to be mapped more accurately while those on the higher side get mapped more aggressively.<br /><br />Many values of x are in the S<x<N range and fewer in the 0<x<S range.<br /><br />Solution 3: Use a 'inverse' mapping.Venkateshhttps://www.blogger.com/profile/15893132887136527161noreply@blogger.comtag:blogger.com,1999:blog-6314876008291942531.post-14955953044224079182010-07-01T03:35:05.621-07:002010-07-01T03:35:05.621-07:00A classic problem when writing plotting software.
...A classic problem when writing plotting software.<br /><br />We assume that N/M = S/T if we want to keep the <br />aspect ratio unchanged.<br /><br />Regardless of the aspect ratio, we should<br />transform the co-ordinates x,y of each datapoint <br />to x * S/N and y * T/MLeohttps://www.blogger.com/profile/17742002772935000604noreply@blogger.com