79 lines
1.4 KiB
C++
Executable File
79 lines
1.4 KiB
C++
Executable File
//
|
|
// Math.hpp
|
|
// amoeba
|
|
//
|
|
// Created by Timothy Prepscius on 12/30/16.
|
|
// Copyright © 2016 Timothy Prepscius. All rights reserved.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "HMatrix.h"
|
|
#include "Matrix3.h"
|
|
#include "Vector3.h"
|
|
|
|
#include <initializer_list>
|
|
#include <tjp/core/types/Types.h>
|
|
|
|
namespace tjp {
|
|
namespace core {
|
|
namespace math {
|
|
|
|
template<typename Real>
|
|
class HMatrix
|
|
{
|
|
public:
|
|
typedef Real value_type;
|
|
|
|
Real v[16];
|
|
|
|
public:
|
|
HMatrix<Real>(std::initializer_list<Real> l);
|
|
HMatrix<Real>(const Matrix3<Real> &m, const Vector3<Real> &t, const Vector3<Real> &s);
|
|
HMatrix<Real>() {}
|
|
|
|
const Real* operator[] (size_t row) const;
|
|
Real* operator[] (size_t row);
|
|
|
|
static const HMatrix<Real> Zero;
|
|
static const HMatrix<Real> Identity;
|
|
|
|
template<typename U>
|
|
HMatrix<U> asType() const
|
|
{
|
|
return HMatrix<U> {
|
|
(U)v[0], (U)v[1], (U)v[2], (U)v[3],
|
|
(U)v[4], (U)v[5], (U)v[6], (U)v[7],
|
|
(U)v[8], (U)v[9], (U)v[10], (U)v[11],
|
|
(U)v[12], (U)v[13], (U)v[14], (U)v[15],
|
|
};
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
template<typename Real>
|
|
const HMatrix<Real> HMatrix<Real>::Zero = {
|
|
0, 0, 0, 0,
|
|
0, 0, 0, 0,
|
|
0, 0, 0, 0,
|
|
0, 0, 0, 0
|
|
};
|
|
|
|
template<typename Real>
|
|
const HMatrix<Real> HMatrix<Real>::Identity = {
|
|
1, 0, 0, 0,
|
|
0, 1, 0, 0,
|
|
0, 0, 1, 0,
|
|
0, 0, 0, 1
|
|
};
|
|
|
|
typedef HMatrix<Real> HMatrixr;
|
|
typedef HMatrix<float> HMatrixf;
|
|
typedef HMatrix<double> HMatrixd;
|
|
|
|
} // namespace
|
|
} // namespace
|
|
} // namespace
|
|
|