+import net.sf.openrocket.logging.LogHelper;
+import net.sf.openrocket.startup.Application;
+
+/**
+ * An immutable quaternion class.
+ *
+ * @author Sampo Niskanen <sampo.niskanen@iki.fi>
+ */
+public class Quaternion {
+ private static final LogHelper log = Application.getLogger();
+
+
+ //////// Debug section
+ /*
+ * Debugging info. If openrocket.debug.quaternioncount is defined, a line is
+ * printed every 1000000 instantiations (or as many as defined).
+ */
+ private static final boolean COUNT_DEBUG;
+ private static final int COUNT_DIFF;
+ static {
+ String str = System.getProperty("openrocket.debug.quaternioncount");
+ int diff = 0;
+ if (str == null) {
+ COUNT_DEBUG = false;
+ COUNT_DIFF = 0;
+ } else {
+ COUNT_DEBUG = true;
+ try {
+ diff = Integer.parseInt(str);
+ } catch (NumberFormatException ignore) {
+ }
+ if (diff < 1000)
+ diff = 1000000;
+ COUNT_DIFF = diff;
+ }
+ }
+
+ private static int count = 0;
+ {
+ // Debug count
+ if (COUNT_DEBUG) {
+ synchronized (Quaternion.class) {
+ count++;
+ if ((count % COUNT_DIFF) == 0) {
+ log.debug("Quaternion instantiated " + count + " times.");
+ }
+ }
+ }
+ }
+
+ //////// End debug section
+