value truncated, undesirable

For the following function, N in "n=" line has 3 values when executed
N=[0, 0, 586218.1824].

When I break it down to C = (N.at<double>(2))the 586218.1824 has been truncated to 586218.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void find_n_ABC(std::vector<cv::Point3d>&n, std::vector<cv::Point3d> &QP, std::vector<cv::Point3d> &RP, double &A, double &B, double &C)

{

	Mat qp(QP);
	Mat rp(RP);
	Mat N(n);
	N = qp.cross(rp);
	std::cout << "n=" << N << std::endl;
	A = (N.at<double>(0));
	B = (N.at<double>(1));
	C = (N.at<double>(2));
	std::cout << "n = <a,b,c> " << A << "," << B << "," << C << std::endl;
}

Why does it get truncated?
Last edited on
How is Poin3d defined?

How is cross() defined and declared?

How is Mat defined?

How is the Mat operator<< defined and declared?
It might just be this:

https://en.cppreference.com/w/cpp/io/manip/setprecision

The default is 6, hence the output.
OpenCV has its own formatting abstraction, which is why it prints its own data types with more (16, probably) significant digits:
https://github.com/opencv/opencv/blob/619180dffdfeb0f72c69a3ef7d1f53fe4435b650/modules/core/include/opencv2/core/cvstd.inl.hpp#L89
Last edited on
This worked great, below, thank you:

1
2
3
4
5
6
...
std::cout << "std::setprecision(10): " << std::setprecision(10) << N << '\n';
	std::cout << "n=" << N << std::endl;
	A = (N.at<double>(0));
	B = (N.at<double>(1));
	C = (N.at<double>(2));


n = 0,0,586218.1824
Topic archived. No new replies allowed.