Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Random values printing a Mat

Hi, I would like to print out a matrix Mat after having written the desired values in it. I'm doing this way:

Mat Rot(3,3, CV_32FC1);

Rot.at<double>(0,0)=cos(roll)*cos(pitch);
Rot.at<double>(0,1)=cos(roll)*sin(pitch)*sin(yaw)-sin(roll)*cos(yaw);
Rot.at<double>(0,2)=cos(roll)*sin(pitch)*cos(yaw)+sin(roll)*sin(yaw);
Rot.at<double>(1,0)=sin(roll)*cos(pitch);
Rot.at<double>(1,1)=sin(roll)*sin(pitch)*sin(yaw)+cos(roll)*cos(yaw);
Rot.at<double>(1,2)=sin(roll)*sin(pitch)*cos(yaw)-cos(roll)*sin(yaw);
Rot.at<double>(2,0)=-sin(pitch);
Rot.at<double>(2,1)=cos(pitch)*sin(yaw);
Rot.at<double>(2,2)=cos(pitch)*cos(yaw);

    cout << " Rot " << Rot << endl;

    cout << " Rot(0,0) " <<   Rot.at<double>(0,0) << endl;

The strange thing is that, when I print out Rot, random values come out but the output of Rot(0,0) is correct!

Any idea? Thanks