private float CorrectInclination_BiggerORSmallerThan90(Common.Plane toothAxisPlane, Vector3 lowestPoint, Common.Plane occlusalPlane)
        {
            Vector3 upperP, lowerP;
            int     lowestSide = occlusalPlane.PointSide(lowestPoint);


            if (occlusalPlane.PointSide(toothAxisPlane.tangentPoints[0]) == lowestSide &&
                occlusalPlane.PointSide(toothAxisPlane.tangentPoints[1]) != lowestSide)
            {
                upperP = toothAxisPlane.tangentPoints[1];
                lowerP = toothAxisPlane.tangentPoints[0];
            }
            else if (occlusalPlane.PointSide(toothAxisPlane.tangentPoints[0]) != lowestSide &&
                     occlusalPlane.PointSide(toothAxisPlane.tangentPoints[1]) == lowestSide)
            {
                upperP = toothAxisPlane.tangentPoints[0];
                lowerP = toothAxisPlane.tangentPoints[1];
            }
            else //error
            {
                upperP = toothAxisPlane.tangentPoints[1];
                lowerP = toothAxisPlane.tangentPoints[0];
                Common.Logger.Log("MainForm", "TeethComputations", "CorrectInclination_BiggerORSmallerThan90",
                                  "Logical Error: both points of toothAxisPlane.tangentPoints were located on the same of the plane", true);
            }

            Vector3 upperPProj = occlusalPlane.ProjectPointOnPlane(upperP);
            Vector3 lowerPProj = occlusalPlane.ProjectPointOnPlane(lowerP);

            float distUpperPProj2Center = (upperPProj - occlusalPlane.centerForDraw).LengthSquared;
            float distLowerPProj2Center = (lowerPProj - occlusalPlane.centerForDraw).LengthSquared;

            if (distUpperPProj2Center < distLowerPProj2Center)
            {
                return(toothAxisPlane.Inclination - 90);
            }
            else
            {
                return(90 - toothAxisPlane.Inclination);
            }
        }
        private Vector3[] FindAndSortPointsOnBuccalSide(Vector3[] projectedPoints, Common.Plane AxisPlane, Common.Plane OcclusalPlane)
        {
            Vector3 center  = AxisPlane.center;
            Vector3 highest = AxisPlane.highestPoint;
            Vector3 lowest  = AxisPlane.lowestPoint;

            //projectedPoints.sor
            tempOcclusalPlaneForPointCompareSort = OcclusalPlane;
            System.Comparison <Vector3> comp = new Comparison <Vector3>(PointCompareOnDistanceToOcclusalPlane);
            Array.Sort <Vector3>(projectedPoints, comp);

            //plane which cut the tooth in half in vertical (medio-lateral)
            Vector3 point3 = new Vector3(highest);

            point3 += AxisPlane.GetNormal();
            Common.Plane halfPlaneOfTooth = new Common.Plane(highest, lowest, point3, "halfPlane", PLANE_DRAW_RADIUS_TOOTH);

            //Testing the halfPlane
            //Planes[SAGITALPLANE_INDEX] = halfPlaneOfTooth;
            //Planes[SAGITALPLANE_INDEX].valid = true;
            //tcb[SAGITALPLANE_INDEX].Enabled = true;
            //tcb[SAGITALPLANE_INDEX].Checked = true;

            int centerSide = halfPlaneOfTooth.PointSide(center);


            List <Vector3> newPoints = new List <Vector3>();

            for (int i = 0; i < projectedPoints.Length; i++)
            {
                //if ((center - highest).Length > (center - projectedPoints[i]).Length) //meaning point is on buccal!
                if (halfPlaneOfTooth.PointSide(projectedPoints[i]) == centerSide)
                {
                    newPoints.Add(projectedPoints[i]);
                }
            }

            //this.Text = newPoints.Count.ToString();
            return(newPoints.ToArray());
        }