Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Usecka {
- public int x1,x2,y1,y2;
- float k, q;
- public void prohod() {
- if (y2 < y1) {
- int p;
- p = y1;
- y1 = y2;
- y2 = p;
- p = x1;
- x1 = x2;
- x2 = p;
- }
- }
- public void vypocti() {
- k = (float) (x2 - x1) / (y2 - y1);
- q = (float) x1 - (k * y1);
- }
- public void zkrat() {
- }
- public boolean jePrusecik(int y) {
- return (y>=y1 && y<y2);
- }
- public int vypoctiPrusecik(int y) {
- /*
- float dx = x1 - x2;
- float dy = y1 - y2;
- float c = dx / dy;
- float x = c * (y - y1) + x1;
- return (int)x;
- */
- return (int) (k*x + q);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment