pborawski

Skala.cs

Apr 23rd, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace WindowsFormsApplication4
  7. {
  8.     class Skala
  9.     {
  10.         public double A, B, C, D;          
  11.         public double E, F, G, H;
  12.        
  13.         public Skala( int xe0, int ye0, int eszer, int ewys, double xr0, double yr0, double rszer, double rwys)
  14.         {
  15.             A = (double) eszer / rszer; //z przestrzeni na ekran
  16.             B = (double) xe0 - A * (xr0 - rszer / 2.0);
  17.             C = -(double)ewys  / rwys;
  18.             D = (double) ye0 - C * (yr0 + rwys / 2.0);
  19.  
  20.             E = rszer / (double)eszer;      //z ekranu do przestrzeni
  21.             F = xr0 - rszer / 2.0 - E * (double)xe0;
  22.             G = -rwys / (double)ewys;
  23.             H = yr0 + rwys  / 2.0 - G * (double)ye0;
  24.         }
  25.         public Skala( int xe0, int eszer, double xr0, double rszer)
  26.         {
  27.             A = (double) eszer / rszer; //z przestrzeni na ekran
  28.             B = (double) xe0 - A * (xr0 - rszer / 2.0);
  29.             C = 0;
  30.             D = 0;
  31.  
  32.             E = rszer / (double)eszer;      //z ekranu do przestrzeni
  33.             F = xr0 - rszer / 2.0 - E * (double)xe0;
  34.             G = 0;
  35.             H = 0;
  36.         }
  37.         public double daj_real_x(int xe)
  38.         {
  39.             return E * xe + F;
  40.         }
  41.         public double daj_real_y(int ye)
  42.         {
  43.             return G * ye + H;
  44.         }
  45.         public int daj_ekr_x(double x)
  46.         {
  47.             return (int)(A * x + B);
  48.         }
  49.         public int daj_ekr_y(double y)
  50.         {
  51.             return (int)(C * y + D);
  52.         }
  53.        
  54.            
  55.        
  56.        
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment