/s/KRQuaternion/Quaternion/
This commit is contained in:
@@ -29,8 +29,8 @@
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#ifndef KRTRIANGLE3_H
|
||||
#define KRTRIANGLE3_H
|
||||
#ifndef KRAKEN_TRIANGLE3_H
|
||||
#define KRAKEN_TRIANGLE3_H
|
||||
|
||||
#include "Vector3.h"
|
||||
|
||||
@@ -62,4 +62,4 @@ public:
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
#endif // KRTRIANGLE3_H
|
||||
#endif // KRAKEN_TRIANGLE3_H
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "vector2.h"
|
||||
#include "vector3.h"
|
||||
#include "vector4.h"
|
||||
#include "Matrix4.h"
|
||||
#include "KRQuaternion.h"
|
||||
#include "matrix4.h"
|
||||
#include "quaternion.h"
|
||||
#include "KRAABB.h"
|
||||
#include "KRTriangle3.h"
|
||||
|
||||
|
||||
115
kraken/public/matrix4.h
Normal file
115
kraken/public/matrix4.h
Normal file
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// Matrix4.h
|
||||
// Kraken
|
||||
//
|
||||
// Copyright 2017 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
|
||||
#include "vector3.h"
|
||||
#include "vector4.h"
|
||||
|
||||
#ifndef KRAKEN_MATRIX4_H
|
||||
#define KRAKEN_MATRIX4_H
|
||||
|
||||
namespace kraken {
|
||||
|
||||
typedef enum {
|
||||
X_AXIS,
|
||||
Y_AXIS,
|
||||
Z_AXIS
|
||||
} AXIS;
|
||||
|
||||
class Quaternion;
|
||||
|
||||
class Matrix4 {
|
||||
public:
|
||||
|
||||
float c[16]; // Matrix components, in column-major order
|
||||
|
||||
// Default constructor - Creates an identity matrix
|
||||
Matrix4();
|
||||
|
||||
Matrix4(float *pMat);
|
||||
|
||||
Matrix4(const Vector3 &axis_x, const Vector3 &axis_y, const Vector3 &axis_z, const Vector3 &trans);
|
||||
|
||||
// Destructor
|
||||
~Matrix4();
|
||||
|
||||
// Copy constructor
|
||||
Matrix4(const Matrix4 &m);
|
||||
|
||||
// Overload assignment operator
|
||||
Matrix4& operator=(const Matrix4 &m);
|
||||
|
||||
// Overload comparison operator
|
||||
bool operator==(const Matrix4 &m) const;
|
||||
|
||||
// Overload compound multiply operator
|
||||
Matrix4& operator*=(const Matrix4 &m);
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
// Overload multiply operator
|
||||
//Matrix4& operator*(const Matrix4 &m);
|
||||
Matrix4 operator*(const Matrix4 &m) const;
|
||||
|
||||
float *getPointer();
|
||||
|
||||
void perspective(float fov, float aspect, float nearz, float farz);
|
||||
void ortho(float left, float right, float top, float bottom, float nearz, float farz);
|
||||
void translate(float x, float y, float z);
|
||||
void translate(const Vector3 &v);
|
||||
void scale(float x, float y, float z);
|
||||
void scale(const Vector3 &v);
|
||||
void scale(float s);
|
||||
void rotate(float angle, AXIS axis);
|
||||
void rotate(const Quaternion &q);
|
||||
void bias();
|
||||
bool invert();
|
||||
void transpose();
|
||||
|
||||
static Vector3 DotNoTranslate(const Matrix4 &m, const Vector3 &v); // Dot product without including translation; useful for transforming normals and tangents
|
||||
static Matrix4 Invert(const Matrix4 &m);
|
||||
static Matrix4 Transpose(const Matrix4 &m);
|
||||
static Vector3 Dot(const Matrix4 &m, const Vector3 &v);
|
||||
static Vector4 Dot4(const Matrix4 &m, const Vector4 &v);
|
||||
static float DotW(const Matrix4 &m, const Vector3 &v);
|
||||
static Vector3 DotWDiv(const Matrix4 &m, const Vector3 &v);
|
||||
|
||||
static Matrix4 LookAt(const Vector3 &cameraPos, const Vector3 &lookAtPos, const Vector3 &upDirection);
|
||||
|
||||
static Matrix4 Translation(const Vector3 &v);
|
||||
static Matrix4 Rotation(const Vector3 &v);
|
||||
static Matrix4 Scaling(const Vector3 &v);
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
#endif // KRAKEN_MATRIX4_H
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// KRQuaternion.h
|
||||
// Quaternion.h
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
@@ -29,40 +29,40 @@
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#ifndef KRQUATERNION_H
|
||||
#define KRQUATERNION_H
|
||||
#ifndef KRAKEN_QUATERNION_H
|
||||
#define KRAKEN_QUATERNION_H
|
||||
|
||||
#include "Vector3.h"
|
||||
#include "vector3.h"
|
||||
|
||||
namespace kraken {
|
||||
|
||||
class KRQuaternion {
|
||||
class Quaternion {
|
||||
public:
|
||||
KRQuaternion();
|
||||
KRQuaternion(float w, float x, float y, float z);
|
||||
KRQuaternion(const KRQuaternion& p);
|
||||
KRQuaternion(const Vector3 &euler);
|
||||
KRQuaternion(const Vector3 &from_vector, const Vector3 &to_vector);
|
||||
~KRQuaternion();
|
||||
Quaternion();
|
||||
Quaternion(float w, float x, float y, float z);
|
||||
Quaternion(const Quaternion& p);
|
||||
Quaternion(const Vector3 &euler);
|
||||
Quaternion(const Vector3 &from_vector, const Vector3 &to_vector);
|
||||
~Quaternion();
|
||||
|
||||
KRQuaternion& operator =( const KRQuaternion& p );
|
||||
KRQuaternion operator +(const KRQuaternion &v) const;
|
||||
KRQuaternion operator -(const KRQuaternion &v) const;
|
||||
KRQuaternion operator +() const;
|
||||
KRQuaternion operator -() const;
|
||||
Quaternion& operator =( const Quaternion& p );
|
||||
Quaternion operator +(const Quaternion &v) const;
|
||||
Quaternion operator -(const Quaternion &v) const;
|
||||
Quaternion operator +() const;
|
||||
Quaternion operator -() const;
|
||||
|
||||
KRQuaternion operator *(const KRQuaternion &v);
|
||||
KRQuaternion operator *(float num) const;
|
||||
KRQuaternion operator /(float num) const;
|
||||
Quaternion operator *(const Quaternion &v);
|
||||
Quaternion operator *(float num) const;
|
||||
Quaternion operator /(float num) const;
|
||||
|
||||
KRQuaternion& operator +=(const KRQuaternion& v);
|
||||
KRQuaternion& operator -=(const KRQuaternion& v);
|
||||
KRQuaternion& operator *=(const KRQuaternion& v);
|
||||
KRQuaternion& operator *=(const float& v);
|
||||
KRQuaternion& operator /=(const float& v);
|
||||
Quaternion& operator +=(const Quaternion& v);
|
||||
Quaternion& operator -=(const Quaternion& v);
|
||||
Quaternion& operator *=(const Quaternion& v);
|
||||
Quaternion& operator *=(const float& v);
|
||||
Quaternion& operator /=(const float& v);
|
||||
|
||||
friend bool operator ==(KRQuaternion &v1, KRQuaternion &v2);
|
||||
friend bool operator !=(KRQuaternion &v1, KRQuaternion &v2);
|
||||
friend bool operator ==(Quaternion &v1, Quaternion &v2);
|
||||
friend bool operator !=(Quaternion &v1, Quaternion &v2);
|
||||
float& operator [](unsigned i);
|
||||
float operator [](unsigned i) const;
|
||||
|
||||
@@ -72,19 +72,19 @@ public:
|
||||
Matrix4 rotationMatrix() const;
|
||||
|
||||
void normalize();
|
||||
static KRQuaternion Normalize(const KRQuaternion &v1);
|
||||
static Quaternion Normalize(const Quaternion &v1);
|
||||
|
||||
void conjugate();
|
||||
static KRQuaternion Conjugate(const KRQuaternion &v1);
|
||||
static Quaternion Conjugate(const Quaternion &v1);
|
||||
|
||||
static KRQuaternion FromAngleAxis(const Vector3 &axis, float angle);
|
||||
static KRQuaternion Lerp(const KRQuaternion &a, const KRQuaternion &b, float t);
|
||||
static KRQuaternion Slerp(const KRQuaternion &a, const KRQuaternion &b, float t);
|
||||
static float Dot(const KRQuaternion &v1, const KRQuaternion &v2);
|
||||
static Quaternion FromAngleAxis(const Vector3 &axis, float angle);
|
||||
static Quaternion Lerp(const Quaternion &a, const Quaternion &b, float t);
|
||||
static Quaternion Slerp(const Quaternion &a, const Quaternion &b, float t);
|
||||
static float Dot(const Quaternion &v1, const Quaternion &v2);
|
||||
private:
|
||||
float m_val[4];
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
#endif // KRQUATERNION_H
|
||||
#endif // KRAKEN_QUATERNION_H
|
||||
Reference in New Issue
Block a user