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