@kq dziękuje za pomoc
A to jak sformatować coś bardziej dziwnego niż struktura ?
Mnożenie macierzy razy wektor
fmt::print("{}", Mat4f * Vec4f);
Mat4f * Vec4f to z mojego punktu widzenia jest Vec4f , ale kompilator c++ widzi to trochę inaczej
fmt wyświetla poprawnie typ Mat4f i Vec4f ale już wynik mnożenia Mat4f * Vec4f jest problememem
https://godbolt.org/z/rxhvhxPc8
#include <Eigen/StdVector>
#include <fmt/format.h>
typedef Eigen::Matrix4f Mat4f;
typedef Eigen::Vector4f Vec4f;
template <> struct fmt::formatter<Vec4f>: formatter<string_view>{
// parse is inherited from formatter<string_view>.
template <typename FormatContext>
auto format(Vec4f v, FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "[{} {} {} {}]", v[0], v[1] , v[2], v[3]);
}
};
template <> struct fmt::formatter<Mat4f>: formatter<string_view>{
// parse is inherited from formatter<string_view>.
template <typename FormatContext>
auto format(Mat4f v, FormatContext& ctx) const {
return fmt::format_to(ctx.out(), "[{} {} {} {}]\n[{} {} {} {}]\n[{} {} {} {}]\n[{} {} {} {}]",
v(0,0), v(0,1) , v(0,2), v(0,3),
v(1,0), v(1,1) , v(1,2), v(1,3),
v(2,0), v(2,1) , v(2,2), v(2,3),
v(3,0), v(3,1) , v(3,2), v(3,3)
);
}
};
int main(){
Mat4f m0;
m0.setIdentity();
Vec4f p0_0(0,0,0,1) ;
Vec4f p1_1(1,1,0,1) ;
Vec4f p100_100(100,1,0,1) ;
fmt::print("m0:\n{}\np0_0:{}\np1_1:{}\np100_100:{}", m0, p0_0 , p1_1, p100_100);
// to dziala
Vec4f p = m0*p0_0;
fmt::print("\n\n{}", p);
// to dziala
fmt::print("\n\n{}", Vec4f( m0*p0_0) );
// to nie dziala !!!!!!!!!!!!!!!!
fmt::print("\n\n{}", m0*p0_0 );
// koza(m0*p0_0);
return 0;
}