# classify if two adjacent surfaces belong to same object

I have a box (cuboid) lying on floor or table. So there are 6 surfaces of the box and 1 surface of the floor. If I take each pair of surface such that the surfaces are "adjacent" to each other, I get two kind of pairings:

1) two surfaces of the box: the surface normals of the surfaces diverge from each other.

2) 1 surface of the box + surface of the floor : the surface normals converge and intersect at an angle of 90 degrees. ( 8o to 100 degrees, if we want to add some tolerance).

I want to distinguish these two cases by representing through a function? What function can distinguish between these two situations?

In both cases, the the normalized dot product of the surface normals is 0, since the angle b/w them is 90 degrees. So this is not the right solution...

• Can you clarify this a bit? Are you looking for a function that can generate surface normals for each surface, or a function to determine whether two surface normals intersect within a given range of angles? – Ian Jul 29 '13 at 3:14
• 1st, I have the surface normals. My aim is not to generate them. 2nd thing, the two situations I mentioned, the two surfaces are perpendicular. So the dot product b/w the corr. surface normals is 0 and hence the angle can be found out as 90 degrees. So thats not the concern. The concern is to find a function where the surface normals really intersect at 90 degrees vs the surface normals do not intersect although angle b/w them may be 90 degrees... Hope it is clear now... – Swagatika Jul 30 '13 at 6:14

It actually makes sense that the dot product in both cases is the same (zero) because the dot product of two vectors does not consider the vectors' origins. Or in other words the math for the dot product places the two vectors at the same origin. In this sense there is no way to distinguish converging or diverging vectors.

I think what you need to do is to consider a midpoint for your surfaces as well as their normals and then you should have a convergence or a divergence. Or try taking a dot product of one surface's normal with the other surface's position or vice versa. You will probably find that positive vs negative numbers in this regard will get the answer you seek.

Or maybe you can use the delta position from one to the other against a normal. See the following sketch. By delta position I mean P1-P2. I hope the diagram helps to clarify. I've drawn two cases: case #1 on the left and case #2 on the right. Calculate the dot product of the two blue vectors or the two red vectors. So, for example:

answer = dot( N[blue], P[red]-P[blue] )


These vectors won't be perpendicular, but the answer will tell you if the one surface is in front of the other or behind it. For case #1 the dot products will be positive. For case #2 the dot products will be negative. In fact, this method will tell you if any two arbitrarily positioned surfaces that meet at a common edge are convex or concave (divergent or convergent). They don't have to be perpendicular.

• Thanks :) Let me rephrase what you have said in 2nd paragraph: 1) surface1 has : midpoint1 and normal1. surface2 has : midpoint2 and normal2. 2) dotpdt(midpoint1, normal2) and dotpdt(midpoint2, normal1) . 3) I should watch the sign of the dotpdts. Is this what you mean? I guess, for perpendicular surfaces, this dot product will give value +/- 1. I am not able to figure out how it will help... Can you please explain a bit more? Also, I did not understand the 3rd paragraph... – Swagatika Aug 2 '13 at 9:21
• @Swagatika, I added a diagram and hopefully some clarification. – Octopus Aug 2 '13 at 16:49
• hmm...Thanks again :) This seems good ... I will implement it and hopefully it will work... – Swagatika Aug 2 '13 at 19:29