/// <summary> /// compares the distance of a plane to a threshold distance. if two points distance is below threshold, it returns true /// </summary> /// <param name="pPlane">the plane containing 3 points</param> /// <param name="pDistance">threshold distance</param> /// <returns>true if below threshold</returns> public static bool comparePlanePoints(PlaneModel pPlane, float pDistance) { if (PointCloud.distanceBetweenPoints(pPlane.point1, pPlane.point2) < pDistance || PointCloud.distanceBetweenPoints(pPlane.point2, pPlane.point3) < pDistance || PointCloud.distanceBetweenPoints(pPlane.point3, pPlane.point1) < pDistance) { return(true); } return(false); }
/// <summary> /// compares two planes for similarity. both normal and offset need to be similar /// </summary> /// <param name="pPlaneA">first plane</param> /// <param name="pPlaneB">second plane</param> /// <param name="varianceValue">allowed variance threshold</param> /// <returns>true if similar, false if not</returns> public static bool comparePlanes(PlaneModel pPlaneA, PlaneModel pPlaneB, float varianceValue) { if (Math.Abs(Math.Abs(pPlaneA.anxPlane.Normal.X) - Math.Abs(pPlaneB.anxPlane.Normal.X)) < varianceValue && Math.Abs(Math.Abs(pPlaneA.anxPlane.Normal.Y) - Math.Abs(pPlaneB.anxPlane.Normal.Y)) < varianceValue && Math.Abs(Math.Abs(pPlaneA.anxPlane.Normal.Z) - Math.Abs(pPlaneB.anxPlane.Normal.Z)) < varianceValue && Math.Abs(Math.Abs(pPlaneA.anxPlane.D) - Math.Abs(pPlaneB.anxPlane.D)) < varianceValue * 2) { return(true); } return(false); }