public class Direction { public float dx; public float dy; public float dz; public Direction() { dx = dy = 0.0F; dz = 1.0F; } public Direction(float dx,float dy,float dz) { this.dx = dx; this.dy = dy; this.dz = dz; } public Direction(Direction d) { dx = d.dx; dy = d.dy; dz = d.dz; } public Direction(Position p1,Position p2) { dx = p2.x-p1.x; dy = p2.y-p1.y; dz = p2.z-p1.z; } public float norme() { return((float) Math.sqrt(dx*dx + dy*dy + dz*dz)); } public void normalise() { float norme = norme(); if ( norme != 0 ) { dx /= norme; dy /= norme; dz /= norme; } } public Direction produitVectoriel(Direction d) { return(new Direction(dy*d.dz - dz*d.dy, dz*d.dx - dx*d.dz, dx*d.dy - dy*d.dx)); } public String toString() { return("["+dx+","+dy+","+dz+"]"); } }