71 lines
1.2 KiB
C++
Executable File
71 lines
1.2 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 "Vector3.hpp"
|
|
#include <initializer_list>
|
|
#include <array>
|
|
|
|
namespace tjp {
|
|
namespace core {
|
|
namespace math {
|
|
|
|
template<typename Real>
|
|
class Matrix3
|
|
{
|
|
public:
|
|
typedef Real value_type;
|
|
|
|
Real v[9];
|
|
|
|
public:
|
|
Matrix3<Real>(std::initializer_list<Real> l)
|
|
{
|
|
int i=0;
|
|
for (auto &r: l)
|
|
v[i++] = r;
|
|
}
|
|
|
|
Matrix3<Real> (const Vector3<Real> &a, const Vector3<Real> &b);
|
|
Matrix3<Real> (const Vector3<Real> &a, const Vector3<Real> &b, const Vector3<Real> &c);
|
|
Matrix3<Real> () {}
|
|
|
|
const Real* operator[] (size_t row) const;
|
|
Real* operator[] (size_t row);
|
|
|
|
Matrix3<Real> transpose() const;
|
|
Matrix3<Real> inverse(Real epsilon) const;
|
|
|
|
static const Matrix3<Real> Zero;
|
|
static const Matrix3<Real> Identity;
|
|
} ;
|
|
|
|
template<typename Real>
|
|
const Matrix3<Real> Matrix3<Real>::Zero = {
|
|
0, 0, 0,
|
|
0, 0, 0,
|
|
0, 0, 0
|
|
};
|
|
|
|
template<typename Real>
|
|
const Matrix3<Real> Matrix3<Real>::Identity = {
|
|
1, 0, 0,
|
|
0, 1, 0,
|
|
0, 0, 1
|
|
};
|
|
|
|
typedef Matrix3<Real> Matrix3r;
|
|
typedef Matrix3<float> Matrix3f;
|
|
typedef Matrix3<double> Matrix3d;
|
|
|
|
} // namespace
|
|
} // namespace
|
|
} // namespace
|
|
|