How to calculate the components of M3C2_distance

Feel free to ask any question here
Post Reply
Riley
Posts: 3
Joined: Mon Jan 15, 2024 4:08 pm

How to calculate the components of M3C2_distance

Post by Riley »

Hi everyone,
I’m a master student. I’ve read the wiki page and author’s article, but I still have some questions about M3C2. I exported the M3C2 results as an ASCII file, and then I obtained the M3C2_distance, Nx, Ny and Nz values. I noticed that if I set the “preferred orientation” as “+Z” when I conducted the analysis, all values in the Nz column are positive. So, I’m confused about whether the plus or minus sign of M3C2_distance only indicates the positive and negative in the Z-direction, or in all the X, Y and Z directions.

For instance, here are the results.
M3C2_distance = -1.38
Nx = -0.79
Ny = -0.56
Nz = 0.26

If I want to calculate the components of M3C2_distance,
(1) The plus or minus sign of M3C2_distance only indicates the positive and negative in the Z direction.
The component in X-direction: (-0.79)*absolute(-1.38) = -1.09
The component in Y-direction: (-0.56)*absolute(-1.38) = -0.77
The component in Z-direction: 0.26*(-1.38) = -0.36
(2) The plus or minus sign of M3C2_distance represent the positive and negative in all X, Y and Z directions.
The component in X-direction: (-0.79)*( -1.38) = 1.09
The component in Y-direction: (-0.56)*(-1.38) = 0.77
The component in Z-direction: 0.26*(-1.38) = -0.36

(1) and (2), which one is correct?
Or do you have a suggestion for calculating the X, Y, Z components of M3C2_distance?

Thank you very much
Best regards,
Riley
daniel
Site Admin
Posts: 7717
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: How to calculate the components of M3C2_distance

Post by daniel »

The answer is (2).

The signed distance is expressed along the point normal vector. Imagine for each point an infinite plane (centered on the point, with the same normal as the point). If equivalent points in the other cloud are found in the half-space on the side pointed by the normal, then distances will be positive, else they will be negative.

And the '+Z' option is just a hint for CC to orient the normals when they are calculated. CC will flip the normal vector -1 if its Z component is negative (if will flip the whole vector, not only its Z component).
Daniel, CloudCompare admin
Post Reply