示例#1
0
 public Converter(PlotParameters parameters)//задание через структуру
 {
     if (parameters.Width < 0 || parameters.Height < 0 || parameters.Xmin >= parameters.Xmax || parameters.Ymin >= parameters.Ymax)
     {
         throw new Exception("Invalid data");
     }
     Width  = parameters.Width;
     Height = parameters.Height;
     Xmax   = parameters.Xmax;
     Xmin   = parameters.Xmin;
     Ymin   = parameters.Ymin;
     Ymax   = parameters.Ymax;
 }
示例#2
0
 public static float YBackConvert(int y, PlotParameters parameters)
 {
     return((y <= parameters.Height && y >= 0) ? parameters.Ymax - ((parameters.Ymax - parameters.Ymin) * (float)y / parameters.Height) : throw new Exception("Cannot backconvert y"));
 }
示例#3
0
 public static int YConvert(float y, PlotParameters parameters)
 {
     return((y >= parameters.Ymin && y <= parameters.Ymax) ? Convert.ToInt32(Math.Round(parameters.Height / (parameters.Ymax - parameters.Ymin) * (parameters.Ymax - y), 0)) : throw new Exception("Cannot convert y"));
 }
示例#4
0
 public static float XBackConvert(int x, PlotParameters parameters)
 {
     return((x <= parameters.Width && x >= 0) ? parameters.Xmin + ((parameters.Xmax - parameters.Xmin) * (float)x / parameters.Width) : throw new Exception("Cannot backconvert x"));
 }
示例#5
0
 //Через структуру
 public static int XConvert(float x, PlotParameters parameters)
 {
     return((x >= parameters.Xmin && x <= parameters.Xmax) ? Convert.ToInt32(Math.Round(parameters.Width / (parameters.Xmax - parameters.Xmin) * (x - parameters.Xmin), 0)) : throw new Exception("Cannot convert x"));
 }