import java.awt.Graphics; public class Joon implements Kujund{ int x1, y1, x2, y2; public Joon(int ux1, int uy1, int ux2, int uy2){ x1=ux1; y1=uy1; x2=ux2; y2=uy2; } public void joonista(Graphics g){ g.drawLine(x1, y1, x2, y2); } public double kaugus(int hx, int hy){ int A=(y2-y1); int B=-(x2-x1); int C=y1*(x2-x1)-x1*(y2-y1); return Math.abs(A*hx+B*hy+C)/Math.sqrt(A*A+B*B); } public boolean kasPihtas(int hx, int hy){ if(hxMath.max(x1, x2)){return false;} if(hyMath.max(y1, y2)){return false;} return kaugus(hx, hy)<=TABAMISKAUGUS; } }