/// <summary> /// Returns the closeness to the specifed value of a specified property. Output is 0 to 1 with 0 being furthest and 1 being closest. /// The output will clamp to max/min values of the given range without exceeding the original range. /// </summary> /// <param name="value"></param> Target value. In original units of the specifies properties. Ie inclination is degrees [0,90]. /// <param name="spread"></param> The spread from taget value. Input values must be from 0 to 1.0. This is mapped to the range of the specified property. Ie 0.2 for inclination is +-18 degrees (original range is 0 to 90) /// <param name="property"></param> The desired property. /// <returns></returns> public float GetCloseness(float value, float spread, BranchPropertyType property) { switch (property) { case BranchPropertyType.Radius: return(Closeness(radius, value, spread, radiusLimit)); case BranchPropertyType.Elevation: return(Closeness(elevation, value, spread, elevationLimit)); case BranchPropertyType.Inclination: return(Closeness(inclanation, value, spread, inclanationLimit)); case BranchPropertyType.Length: return(Closeness(length, value, spread, lengthLimit)); case BranchPropertyType.DistanceToTip: return(Closeness(distanceToTip, value, spread, distanceToTipLimit)); case BranchPropertyType.Exposure: return(branch.GetCloseness(value, spread, property)); default: return(0); } }
float getProperty(BranchLineInfo branch, BranchPropertyType type) { switch (type) { case BranchPropertyType.Radius: return(1 - branch.RadiusPercentage); case BranchPropertyType.Elevation: return(branch.ElevationPercentage); case BranchPropertyType.Inclination: return(1 - branch.InclanationPercentage); case BranchPropertyType.Length: return(branch.LengthPercentage); case BranchPropertyType.DistanceToTip: return(1 - branch.DistanceToTipPercentage); case BranchPropertyType.Exposure: return(branch.branch.ExposurePercentage); default: break; } return(0); }