tuxmartin

PGRF1 - cviceni 14.11.2011

Nov 16th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. public class Usecka {
  2.         public int x1,x2,y1,y2;
  3.         float k, q;
  4.  
  5.         public void prohod() {
  6.             if (y2 < y1) {
  7.                 int p;
  8.                 p = y1;
  9.                 y1 = y2;
  10.                 y2 = p;
  11.                 p = x1;
  12.                 x1 = x2;
  13.                 x2 = p;
  14.  
  15.             }
  16.         }
  17.        
  18.         public void vypocti() {
  19.             k = (float) (x2 - x1) / (y2 - y1);
  20.             q = (float) x1 - (k * y1);
  21.                        
  22.         }
  23.        
  24.         public void zkrat() {
  25.            
  26.         }
  27.        
  28.         public boolean jePrusecik(int y) {
  29.             return (y>=y1 && y<y2);
  30.         }
  31.        
  32.         public int vypoctiPrusecik(int y) {
  33.             /*
  34.             float dx = x1 - x2;
  35.             float dy = y1 - y2;
  36.             float c = dx / dy;
  37.             float x = c * (y - y1) + x1;
  38.             return (int)x;
  39.             */
  40.             return (int) (k*x + q);
  41.         }
  42.  
  43.  
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment