<commit_before>/** @constructor */
function State3D() {}

/** @type {Array<number>} */
State3D.prototype.mouseCoord = [0, 0];

/** @type {boolean} */
State3D.prototype.ortho = false;

/** @type {boolean} */
State3D.prototype.rotating = false;

/** @type {Quaternion} */
State3D.prototype.rotation = Quaternion.fromLatLong(0, 0);

/** @type {boolean} */
State3D.prototype.rotationEasing = true;

/** @type {Quaternion} */
State3D.prototype.target0 = Quaternion.fromLatLong(0, 0);

/** @type {Quaternion} */
State3D.prototype.target1 = Quaternion.fromLatLong(0, 0);

/** @type {boolean} */
State3D.prototype.twoD = false;

/** @type {number} */
State3D.prototype.zoomFactor = 1;

/** @return {Array<number>} */
State3D.identityMatrix = function() {
    return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
};

/** @return {boolean} */
State3D.prototype.isRotating = function() {
    return this.rotating || Quaternion.sub(this.rotation, this.target1).abs() >
        1e-6;
};

/** @param {number} theta
 *  @param {number} phi
 *  @return {function(boolean) : State3D} */
State3D.fromLatLong = function(theta, phi) {
    return function(ortho) {
        var q = Quaternion.fromLatLong(theta, phi),
            st = new State3D();
        st.ortho = ortho;
        st.rotation = st.target0 = st.target1 = q;
        return st;
    };
};

/** @type {function(boolean) : State3D} */
State3D.backView = State3D.fromLatLong(Math.PI / 2, Math.PI);
/** @type {function(boolean) : State3D} */
State3D.frontView = State3D.fromLatLong(Math.PI / 2, 0);
/** @type {function(boolean) : State3D} */
State3D.topView = State3D.fromLatLong(0, 0);
/** @type {function(boolean) : State3D} */
State3D.bottomView = State3D.fromLatLong(Math.PI, 0);
/** @type {function(boolean) : State3D} */
State3D.leftView = State3D.fromLatLong(Math.PI / 2, -Math.PI / 2);
/** @type {function(boolean) : State3D} */
State3D.rightView = State3D.fromLatLong(Math.PI / 2, Math.PI / 2);
/** @param {number} lat
 *  @param {number} long
 *  @param {boolean} ortho
 *  @return {State3D} */
State3D.fromLatLongDegrees = function(lat, long, ortho) {
    return (State3D.fromLatLong(lat / 180 * Math.PI, long / 180 * Math.PI))
        (ortho);
};
/** @return {State3D} */
State3D.twoDimensionalView = function() {
    var st = State3D.topView(true);
    st.twoD = true;
    return st;
};

/** @return {Array<number>} */
State3D.prototype.modelMatrix = function() {
    return this.rotation.rotationMatrix();
};

/** @param {Array<number>} xy */
State3D.prototype.mouseDown = function(xy) {
    this.mouseCoord = xy;
    this.rotating = true;
    this.target0 = this.target1;
};

/** @param {number} x
 *  @param {number} y */
State3D.prototype.mouseMove = function(x, y) {
    if (!(this.rotating))
        return;
    var xy = this.mouseCoord,
        xo = xy[0],
        yo = xy[1],<commit_msg>Refactor State3D factory functions<commit_after>/** @constructor */
function State3D() {}

/** @type {Array<number>} */
State3D.prototype.mouseCoord = [0, 0];

/** @type {boolean} */
State3D.prototype.ortho = false;

/** @type {boolean} */
State3D.prototype.rotating = false;

/** @type {Quaternion} */
State3D.prototype.rotation = Quaternion.fromLatLong(0, 0);

/** @type {boolean} */
State3D.prototype.rotationEasing = true;

/** @type {Quaternion} */
State3D.prototype.target0 = Quaternion.fromLatLong(0, 0);

/** @type {Quaternion} */
State3D.prototype.target1 = Quaternion.fromLatLong(0, 0);

/** @type {boolean} */
State3D.prototype.twoD = false;

/** @type {number} */
State3D.prototype.zoomFactor = 1;

/** @return {Array<number>} */
State3D.identityMatrix = function() {
    return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
};

/** @return {boolean} */
State3D.prototype.isRotating = function() {
    return this.rotating || Quaternion.sub(this.rotation, this.target1).abs() >
        1e-6;
};

/** @param {number} theta
 *  @param {number} phi
 *  @param {boolean} ortho
 *  @return {State3D} */
State3D.fromLatLong = function(theta, phi, ortho) {
    var q = Quaternion.fromLatLong(theta, phi),
        st = new State3D();
    st.ortho = ortho;
    st.rotation = st.target0 = st.target1 = q;
    return st;
};

/** @type {function(boolean) : State3D} */
State3D.backView = State3D.fromLatLong.bind(null, Math.PI / 2, Math.PI);
/** @type {function(boolean) : State3D} */
State3D.frontView = State3D.fromLatLong.bind(null, Math.PI / 2, 0);
/** @type {function(boolean) : State3D} */
State3D.topView = State3D.fromLatLong.bind(null, 0, 0);
/** @type {function(boolean) : State3D} */
State3D.bottomView = State3D.fromLatLong.bind(null, Math.PI, 0);
/** @type {function(boolean) : State3D} */
State3D.leftView = State3D.fromLatLong.bind(null, Math.PI / 2, -Math.PI / 2);
/** @type {function(boolean) : State3D} */
State3D.rightView = State3D.fromLatLong.bind(null, Math.PI / 2, Math.PI / 2);
/** @param {number} lat
 *  @param {number} lon
 *  @param {boolean} ortho
 *  @return {State3D} */
State3D.fromLatLongDegrees = function(lat, lon, ortho) {
    var piOver180 = Math.PI / 180;
    return State3D.fromLatLong(lat * piOver180, lon * piOver180, ortho);
};
/** @return {State3D} */
State3D.twoDimensionalView = function() {
    var st = State3D.topView(true);
    st.twoD = true;
    return st;
};

/** @return {Array<number>} */
State3D.prototype.modelMatrix = function() {
    return this.rotation.rotationMatrix();
};

/** @param {Array<number>} xy */
State3D.prototype.mouseDown = function(xy) {
    this.mouseCoord = xy;
    this.rotating = true;
    this.target0 = this.target1;
};

/** @param {number} x
 *  @param {number} y */
State3D.prototype.mouseMove = function(x, y) {
    if (!(this.rotating))
        return;
    var xy = this.mouseCoord,
        xo = xy[0],
        yo = xy[1],
{'fraction_non_alphanumeric': 0.18702290076335878, 'fraction_numerical': 0.03383067314365024, 'mean_word_length': 3.5357985837922894, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '64804', 'n_tokens_mistral': 2232, 'n_tokens_neox': 2153, 'n_words': 441}