Пример #1
0
 /**
  * Constructs OscillatorsMode with the given mode and number of particles.
  *
  * <p>The particle separation is one in this model.
  *
  * @param mode int
  * @param N int
  */
 OscillatorsMode(int mode, int N) {
   amplitude = Math.sqrt(2.0 / (N + 1));
   omega = 2 * Math.sqrt(OMEGA_SQUARED) * Math.abs(Math.sin(mode * Math.PI / N / 2));
   wavenumber = Math.PI * mode / (N + 1);
   functionDrawer = new FunctionDrawer(this);
   functionDrawer.initialize(0, N + 1, 300, false); // draws the initial displacement
   functionDrawer.color = Color.LIGHT_GRAY;
 }
Пример #2
0
 /**
  * Creates an AffineMatrix representing a rotation about the origin by some angle around the given
  * axis.
  *
  * @param theta double
  * @param axis double[]
  * @return AffineMatrix
  */
 public static Affine3DMatrix Rotation(double theta, double[] axis) {
   Affine3DMatrix at = new Affine3DMatrix(null);
   double[][] atMatrix = at.matrix;
   double norm = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]);
   double x = axis[0] / norm, y = axis[1] / norm, z = axis[2] / norm;
   double c = Math.cos(theta), s = Math.sin(theta);
   double t = 1 - c;
   // matrix elements not listed are zero
   atMatrix[0][0] = t * x * x + c;
   atMatrix[0][1] = t * x * y - s * z;
   atMatrix[0][2] = t * x * y + s * y;
   atMatrix[1][0] = t * x * y + s * z;
   atMatrix[1][1] = t * y * y + c;
   atMatrix[1][2] = t * y * z - s * x;
   atMatrix[2][0] = t * x * z - s * y;
   atMatrix[2][1] = t * y * z + s * x;
   atMatrix[2][2] = t * z * z + c;
   atMatrix[3][3] = 1;
   return at;
 }