working a bit to get the constructor usage cleaned up for the whole matrix code

This commit is contained in:
Hartmut Seichter 2019-01-21 15:46:57 +01:00
parent f33e6769f4
commit bf834a33e0
11 changed files with 293 additions and 163 deletions

View file

@ -5,20 +5,20 @@ add_executable(pwcore_test_matrix
target_link_libraries(pwcore_test_matrix
pwcore)
#add_executable(pwcore_test_vector
# pwcore_test_vector.cpp
# )
add_executable(pwcore_test_vector
pwcore_test_vector.cpp
)
#target_link_libraries(pwcore_test_vector
# pwcore)
target_link_libraries(pwcore_test_vector
pwcore)
#add_executable(pwcore_test_quaternion
# pwcore_test_quaternion.cpp
# )
add_executable(pwcore_test_quaternion
pwcore_test_quaternion.cpp
)
#target_link_libraries(pwcore_test_quaternion
# pwcore)
target_link_libraries(pwcore_test_quaternion
pwcore)
add_executable(pwcore_test_axisangle

View file

@ -8,7 +8,7 @@ int main(int argc,char **argv) {
pw::axisangle_<float> aa = pw::axisangle_<float>();
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;

View file

@ -37,7 +37,7 @@ int main(int argc,char **argv) {
vector2f v2;
v2[0] = 1; v2[1] = 3;
vector2f v3(1.f,2.f);
vector2f v3( { 1.f,2.f } );
auto m22_inv = m22.inverse();
auto m22_id = m22_inv * m22;
@ -65,8 +65,11 @@ int main(int argc,char **argv) {
std::cout << "v2_b.norm " << v2_b.norm() << std::endl;
v2_b.normalize();
std::cout << "v2_b.normalized " << v2_b << std::endl;
// v2_b.normalize();
std::cout << "v2_b.normalized " << v2_b.normalized() << std::endl;
std::cout << "v2_b~v3_t " << rad_to_deg(vector2f::angle_between(v2,v3)) << std::endl;

View file

@ -5,22 +5,24 @@
int main(int argc,char **argv) {
pw::quaternion_<float> qf = pw::quaternionf::rotate_90_degree_around_x();
pw::quaternion_<float> qf;
std::cout << "qf = " << pw::serialize::matrix(qf.as_vector()) << std::endl;
std::cout << "qf = " << pw::serialize::matrix(qf) << std::endl;
std::cout << "qf.matrix() = " << pw::serialize::matrix(qf.to_matrix()) << std::endl;
std::cout << "qf.squared_norm() = " << qf.squared_norm() << std::endl;
std::cout << "qf.dot(qf) = " << qf.dot(qf) << std::endl;
std::cout << "qf.conjugate() = " << pw::serialize::matrix(qf.conjugate().as_vector()) << std::endl;
// std::cout << "qf.dot(qf) = " << qf.dot(qf) << std::endl;
std::cout << "qf.conjugate() = " << pw::serialize::matrix(qf.conjugate()) << std::endl;
pw::quaternionf qi = qf.inverse();
std::cout << "qf.inverse() (qi) = " << pw::serialize::matrix(qi.as_vector()) << std::endl;
pw::quaternionf qc = qf.conjugate();
std::cout << "qf.conjugate() (qc) = " << pw::serialize::matrix(qc) << std::endl;
pw::quaternionf qi = qf.inverse();
std::cout << "qf.inverse() (qi) = " << pw::serialize::matrix(qi) << std::endl;
pw::quaternionf qmid = pw::quaternionf::normalized_lerp(qi,qf,0.5f);
// pw::quaternionf qmid = pw::quaternionf::normalized_lerp(qi,qf,0.5f);
std::cout << "qmid.dot() (half between qf and qi) = " << pw::rad_to_deg(std::acos(qmid.dot(qf))) << std::endl;
// std::cout << "qmid.dot() (half between qf and qi) = " << pw::rad_to_deg(std::acos(qmid.dot(qf))) << std::endl;

View file

@ -7,20 +7,25 @@
int main(int argc,char **argv) {
pw::vector4_<float> v4;
pw::vector3f v;
v4.fill(1.5);
std::cout << "v4 = " << pw::serialize::matrix(v4) << std::endl;
std::cout << "row_stride() : " << v4.row_stride() << std::endl;
std::cout << "col_stride() : " << v4.col_stride() << std::endl;
std::cout << "rows() : " << v4.rows() << std::endl;
std::cout << "cols() : " << v4.cols() << std::endl;
std::cout << "data() : " << v4.data() << std::endl;
std::cout << "data()[0] : " << v4.data()[0] << std::endl;
std::cout << "at(0,0) : " << v4.at(0,0) << std::endl;
std::cout << "ptr() : " << v4.ptr() << std::endl;
std::cout << "ptr()[0] : " << v4.ptr()[0] << std::endl;
std::cout << "(0,0) : " << v4(0,0) << std::endl;
pw::vector3f v3 = v4.xyz();
auto v3 = v4.xyz();
auto v3_p = v4.project();
auto v3_h = v.homogenous();
// auto v3_lerp = vector4f::lerp()
std::cout << "v3 = " << pw::serialize::matrix(v3) << std::endl;