still not yet there
This commit is contained in:
parent
9dd862018b
commit
f33e6769f4
7 changed files with 33 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
set(hdrs
|
set(hdrs
|
||||||
include/pw/core/debug.hpp
|
include/pw/core/debug.hpp
|
||||||
# include/pw/core/axisangle.hpp
|
include/pw/core/axisangle.hpp
|
||||||
include/pw/core/core.hpp
|
include/pw/core/core.hpp
|
||||||
include/pw/core/math.hpp
|
include/pw/core/math.hpp
|
||||||
include/pw/core/matrixbase.hpp
|
include/pw/core/matrixbase.hpp
|
||||||
|
|
|
@ -62,8 +62,8 @@ public:
|
||||||
|
|
||||||
const T _fCos = cos(_angle);
|
const T _fCos = cos(_angle);
|
||||||
|
|
||||||
matrix_<3,1,T> _vCos(_axis * (1 - _fCos));
|
vector3_<T> _vCos(_axis * (1 - _fCos));
|
||||||
matrix_<3,1,T> _vSin(_axis * sin(_angle));
|
vector3_<T> _vSin(_axis * sin(_angle));
|
||||||
|
|
||||||
// R.at(0) = (_axis(0,0) * _vCos(0,0)) + _fCos;
|
// R.at(0) = (_axis(0,0) * _vCos(0,0)) + _fCos;
|
||||||
// R.at(4) = (T) ((vec(0,0) * _vCos(1,0)) - _vSin(2,0));
|
// R.at(4) = (T) ((vec(0,0) * _vCos(1,0)) - _vSin(2,0));
|
||||||
|
|
|
@ -123,10 +123,10 @@ public:
|
||||||
inline void normalize() { *this = this->normalized(); }
|
inline void normalize() { *this = this->normalized(); }
|
||||||
|
|
||||||
//! conversion from a matrix
|
//! conversion from a matrix
|
||||||
inline static const quaternion_ from_matrix(const matrix_<4,4,T> &m);
|
inline static const quaternion_ from_matrix(const matrix_<T,4,4> &m);
|
||||||
|
|
||||||
//! conversion to a matrix
|
//! conversion to a matrix
|
||||||
const matrix_<4,4,T> to_matrix() const;
|
const matrix_<T,4,4> to_matrix() const;
|
||||||
|
|
||||||
//! return identiy quaternion
|
//! return identiy quaternion
|
||||||
static const quaternion_<T> identity();
|
static const quaternion_<T> identity();
|
||||||
|
@ -170,7 +170,7 @@ const T quaternion_<T>::_sqrt90 = std::sqrt(0.5);
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const quaternion_<T> quaternion_<T>::from_matrix(const matrix_<4,4,T> &m) {
|
const quaternion_<T> quaternion_<T>::from_matrix(const matrix_<T,4,4> &m) {
|
||||||
|
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ const quaternion_<T> quaternion_<T>::from_matrix(const matrix_<4,4,T> &m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const matrix_<4,4,T> quaternion_<T>::to_matrix() const {
|
const matrix_<T,4,4> quaternion_<T>::to_matrix() const {
|
||||||
|
|
||||||
matrix_<4,4,T> m; m.set_identity();
|
matrix_<T,4,4> m; m.set_identity();
|
||||||
|
|
||||||
T xx = x() * x();
|
T xx = x() * x();
|
||||||
T xy = x() * y();
|
T xy = x() * y();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef PW_CORE_SERIALIZE_HPP
|
#ifndef PW_CORE_SERIALIZE_HPP
|
||||||
#define PW_CORE_SERIALIZE_HPP
|
#define PW_CORE_SERIALIZE_HPP
|
||||||
|
|
||||||
#include <pw/core/matrixbase.hpp>
|
#include <pw/core/matrix.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -33,8 +33,8 @@ namespace pw {
|
||||||
|
|
||||||
struct serialize {
|
struct serialize {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T,size_t R,size_t C>
|
||||||
inline static std::string matrix(const matrixbase<T>& m) {
|
inline static std::string matrix(const matrix_<T,R,C>& m) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
for (int r = 0; r < m.rows();r++) {
|
for (int r = 0; r < m.rows();r++) {
|
||||||
|
|
|
@ -64,12 +64,27 @@ auto dot(const vector_<T, N, RowMajor>& a, const vector_<U, N, RowMajor>& b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct vector3_ : vector_<T,3> {
|
||||||
|
|
||||||
|
using vector_<T,3>::vector_;
|
||||||
|
|
||||||
|
inline static vector3_<T> forward() { return vector3_<T> ( T(0), T(0),-T(1) ); }
|
||||||
|
inline static vector3_<T> backward() { return vector3_<T>( T(0), T(0), T(1) ); }
|
||||||
|
inline static vector3_<T> right() { return vector3_<T> ( T(1), T(0), T(0) ); }
|
||||||
|
inline static vector3_<T> left() { return vector3_<T> ( -T(1), T(0), T(0) ); }
|
||||||
|
inline static vector3_<T> up() { return vector3_<T> ( T(0), T(1), T(0) ); }
|
||||||
|
inline static vector3_<T> down() { return vector3_<T> ( T(0),-T(1), T(0) ); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
template <typename T> using vector2_ = vector_<T, 2>;
|
template <typename T> using vector2_ = vector_<T, 2>;
|
||||||
template <typename T> using vector3_ = vector_<T, 3>;
|
//template <typename T> using vector3_ = vector_<T, 3>;
|
||||||
template <typename T> using vector4_ = vector_<T, 4>;
|
template <typename T> using vector4_ = vector_<T, 4>;
|
||||||
|
|
||||||
using vector2f = vector2_<float>;
|
using vector2f = vector2_<float>;
|
||||||
|
|
|
@ -21,9 +21,9 @@ target_link_libraries(pwcore_test_matrix
|
||||||
# pwcore)
|
# pwcore)
|
||||||
|
|
||||||
|
|
||||||
#add_executable(pwcore_test_axisangle
|
add_executable(pwcore_test_axisangle
|
||||||
# pwcore_test_axisangle.cpp
|
pwcore_test_axisangle.cpp
|
||||||
# )
|
)
|
||||||
|
|
||||||
#target_link_libraries(pwcore_test_axisangle
|
target_link_libraries(pwcore_test_axisangle
|
||||||
# pwcore)
|
pwcore)
|
||||||
|
|
|
@ -10,7 +10,7 @@ int main(int argc,char **argv) {
|
||||||
|
|
||||||
pw::quaternionf qf = pw::quaternionf::from_axisangle(aa);
|
pw::quaternionf qf = pw::quaternionf::from_axisangle(aa);
|
||||||
|
|
||||||
std::cout << "aa as quaternion as vector = " << pw::serialize::matrix(qf.as_vector()) << std::endl;
|
// std::cout << "aa as quaternion as vector = " << pw::serialize::matrix(qf.as_vector()) << std::endl;
|
||||||
|
|
||||||
// std::cout << "aa.matrix() = " << pw::serialize::matrix(qf.to_matrix()) << std::endl;
|
// std::cout << "aa.matrix() = " << pw::serialize::matrix(qf.to_matrix()) << std::endl;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue