/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Octobre 2008 */ /* Une classe transformation geometrique rotation */ public class Rotation3D extends TransformationGeometrique3D { public Rotation3D() { super(); } public Rotation3D(double a, double dx,double dy,double dz) throws ArithmeticException { super(); remplissage(a,dx,dy,dz); } public Rotation3D(double a, Direction3D d) throws ArithmeticException { super(); remplissage(a,d.getX(),d.getY(),d.getZ()); } public Rotation3D(Rotation3D rt) { super(rt); } private void remplissage(double a, double x,double y,double z) throws ArithmeticException { a = a/180.0*(double) Math.PI; double c = Math.cos(a); double s = Math.sin(a); double d = Math.sqrt(x*x+y*y+z*z); if ( d == 0 ) { throw new ArithmeticException(); } x /= d; y /= d; z /= d; double x2 = x*x; double y2 = y*y; double z2 = z*z; double xs = x*s; double ys = y*s; double zs = z*s; double mc = 1.0 - c; double xymc = x*y*mc; double xzmc = x*z*mc; double yzmc = y*z*mc; this.c[0][0] = x2+c*(1.0-x2); this.c[0][1] = xymc-zs; this.c[0][2] = xzmc+ys; this.c[1][0] = xymc+zs; this.c[1][1] = y2+c*(1.0-y2); this.c[1][2] = yzmc-xs; this.c[2][0] = xzmc-ys; this.c[2][1] = yzmc+xs; this.c[2][2] = z2+c*(1.0-z2); } }