コード例 #1
0
ファイル: CBranch.cs プロジェクト: ja003/ForestReco2
        public float GetDefinedFactor()
        {
            List <CTreePoint> topTreePoints = TreePoints;

            if (topTreePoints.Count == 0)
            {
                return(0);
            }
            if (TreePoints.Count < CTreeManager.MIN_BRANCH_POINT_COUNT)
            {
                int allTreePointsCount = tree.GetAllPoints().Count;
                if (allTreePointsCount < CTreeManager.MIN_TREE_POINT_COUNT)
                {
                    return(0);
                }
            }

            float height           = tree.GetTreeHeight();
            float distLowestToPeak = Vector3.Distance(TreePoints.Last().Center, tree.peak.Center);

            float lowestPointRatio = (distLowestToPeak + GetMinDefinedHeightOffset(height)) / height;

            int       treePointCount    = TreePoints.Count;
            const int minPointsPerMeter = 3;
            //float pointCountRatio = treePointCount / (height * minPointsPerMeter);
            float pointCountRatio = treePointCount / (distLowestToPeak * minPointsPerMeter);

            pointCountRatio = Math.Min(pointCountRatio, 1);

            float factor = (lowestPointRatio + pointCountRatio) / 2;

            return(factor);
        }
コード例 #2
0
ファイル: CBranch.cs プロジェクト: ja003/ForestReco2
 private Vector3 GetLastPoint()
 {
     return(TreePoints.Count == 0 ? tree.peak.Center : TreePoints.Last().Center);
 }