/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Octobre 2007 */ /* Une classe direction en coordonnees homogenes */ public class Direction extends CoordonneesHomogenes { public Direction() { super(0.0F,0.0F,1.0F,0.0F); } public Direction(float x,float y,float z) { super(x,y,z,0.0F); } public Direction(Direction p) { super(p); } public Direction(Position pi, Position pf) throws ArithmeticException { float dx = pf.c[0]-pi.c[0]; float dy = pf.c[1]-pi.c[1]; float dz = pf.c[2]-pi.c[2]; float d =(float) Math.sqrt(dx*dx+dy*dy+dz*dz); if ( d == 0.0F ) { throw new ArithmeticException(); } c = new float[4]; c[0] = dx/d; c[1] = dy/d; c[2] = dz/d; c[3] = 0.0F; } }