The plane fitting example fits a cube on a plane that it created from the point cloud that it retrieves based on the point selected by user. I want to determine if that point is a floor, a wall or a roof. What I am trying to achieve is to change the example so that it only renders the cube on the floor and not on wall or roof.
Asked
Active
Viewed 532 times
2 Answers
0
The simplest solution is to check the plane normal. Usually, wall's normal is perpendicular to the gravity, and floor is parallel to gravity.

xuguo
- 1,816
- 1
- 11
- 15
-
Yes, but how to calculate the amgle between two vectors in 3d space ? – Viraj Nagar Aug 22 '16 at 20:10
0
Something like this:
You got the normal of the plane hit right?
float surfaceAngle = Vector3.Angle(normal, new Vector3(0,1,0));
float floorLimitAngle = 20;
float ceilingLimitAngle = 180 - 20;
if (surfaceAngle < floorLimitAngle )
// It's a floor
else if (surfaceAngle > ceilingLimitAngle)
// It's a ceiling
else
// It's a wall

Trionet
- 149
- 1
- 5