<commit_before>//
// This file is part of the Marble Desktop Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2004-2007 <NAME> <<EMAIL>>"
// Copyright 2007      <NAME>  <<EMAIL>>"
//

//
// Quaternions provides a class that deals with quaternion operations.

// krazy:excludeall=dpointer,inline

#ifndef MARBLE_QUATERNION_H
#define MARBLE_QUATERNION_H

#include "marble_export.h"
#include <cmath>

namespace Marble
{

using std::cos;
using std::sin;

enum
{
    Q_X = 0,
    Q_Y = 1,
    Q_Z = 2,
    Q_W = 3
};


typedef qreal    xmmfloat[4];
typedef xmmfloat  matrix[3];


class MARBLE_EXPORT Quaternion {
 public:
    Quaternion();
    Quaternion(qreal w, qreal x, qreal y, qreal z);
    /*!\brief used to generate Quaternion from longitude and latitude
     * 
     * \param lon longitude
     * \param lat latitude
     */
    Quaternion(qreal lon, qreal lat);

    // Operators
    Quaternion  operator*(const Quaternion &q) const;
    bool        operator==(const Quaternion &q) const;
    Quaternion& operator*=(const Quaternion &q);

    void        set(qreal w, qreal x, qreal y, qreal z) {
	v[Q_W] = w; v[Q_X] = x; v[Q_Y] = y; v[Q_Z] = z;
    }
    void        set(qreal lon, qreal lat) {
        v[Q_W] = 0.0;
        const qreal  cosLat = cos(lat);
        v[Q_X] = cosLat * sin(lon);
        v[Q_Y] = sin(lat);
        v[Q_Z] = cosLat * cos(lon);
    }

    void        getSpherical(qreal &lon, qreal &lat) const;

    void        normalize();

    Quaternion  inverse() const;

    void        createFromEuler(qreal pitch, qreal yaw, qreal roll);
    qreal       pitch() const;
    qreal       yaw() const;
    qreal       roll() const;


    void        display() const;

    void        rotateAroundAxis(const Quaternion &q);

    void        slerp(const Quaternion &q1, const Quaternion &q2, qreal t);
    void        nlerp(const Quaternion &q1, const Quaternion &q2, qreal t);

    void        scalar(qreal mult);

    void        toMatrix(matrix &m) const;
    void        rotateAroundAxis(const matrix &m);

    // TODO: Better add accessors...
    xmmfloat    v;
};

}

#endif // MARBLE_QUATERNION_H<commit_msg>Move definitions of inline methods out of class body to improve readability.<commit_after>//
// This file is part of the Marble Desktop Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2004-2007 <NAME> <<EMAIL>>"
// Copyright 2007      <NAME>  <<EMAIL>>"
//

//
// Quaternions provides a class that deals with quaternion operations.

// krazy:excludeall=dpointer,inline

#ifndef MARBLE_QUATERNION_H
#define MARBLE_QUATERNION_H

#include "marble_export.h"
#include <cmath>

namespace Marble
{

using std::cos;
using std::sin;

enum
{
    Q_X = 0,
    Q_Y = 1,
    Q_Z = 2,
    Q_W = 3
};


typedef qreal    xmmfloat[4];
typedef xmmfloat  matrix[3];


class MARBLE_EXPORT Quaternion {
 public:
    Quaternion();
    Quaternion(qreal w, qreal x, qreal y, qreal z);
    /*!\brief used to generate Quaternion from longitude and latitude
     * 
     * \param lon longitude
     * \param lat latitude
     */
    Quaternion(qreal lon, qreal lat);

    // Operators
    Quaternion  operator*(const Quaternion &q) const;
    bool        operator==(const Quaternion &q) const;
    Quaternion& operator*=(const Quaternion &q);

    void        set(qreal w, qreal x, qreal y, qreal z);
    void        set(qreal lon, qreal lat);

    void        getSpherical(qreal &lon, qreal &lat) const;

    void        normalize();

    Quaternion  inverse() const;

    void        createFromEuler(qreal pitch, qreal yaw, qreal roll);
    qreal       pitch() const;
    qreal       yaw() const;
    qreal       roll() const;


    void        display() const;

    void        rotateAroundAxis(const Quaternion &q);

    void        slerp(const Quaternion &q1, const Quaternion &q2, qreal t);
    void        nlerp(const Quaternion &q1, const Quaternion &q2, qreal t);

    void        scalar(qreal mult);

    void        toMatrix(matrix &m) const;
    void        rotateAroundAxis(const matrix &m);

    // TODO: Better add accessors...
    xmmfloat    v;
};

inline void Quaternion::set( qreal w, qreal x, qreal y, qreal z )
{
    v[Q_W] = w;
    v[Q_X] = x;
    v[Q_Y] = y;
    v[Q_Z] = z;
}

inline void Quaternion::set( qreal lon, qreal lat )
{
    v[Q_W] = 0.0;
    const qreal cosLat = cos( lat );
    v[Q_X] = cosLat * sin( lon );
    v[Q_Y] = sin( lat );
    v[Q_Z] = cosLat * cos( lon );
}

}

#endif // MARBLE_QUATERNION_H
{'fraction_non_alphanumeric': 0.11252383979656706, 'fraction_numerical': 0.010171646535282899, 'mean_word_length': 2.437727603787327, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4893182', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1633, 'n_words': 510}