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