Ejemplo n.º 1
0
        public float Calculate(IHeightStickParameters heightDescription)
        {
            var heightRange = heightDescription.HeightRange;

            switch (heightDescription.HeightType)
            {
            case HeightfieldTypes.Float:
                return(1f);

            case HeightfieldTypes.Short:
                return(Math.Max(Math.Abs(heightRange.X), Math.Abs(heightRange.Y)) / short.MaxValue);

            case HeightfieldTypes.Byte:
                if (Math.Abs(heightRange.X) <= Math.Abs(heightRange.Y))
                {
                    return(heightRange.Y / byte.MaxValue);
                }
                else
                {
                    return(heightRange.X / byte.MaxValue);
                }

            default:
                throw new NotSupportedException($"Unknown height type.");
            }
        }
Ejemplo n.º 2
0
 public float Calculate(IHeightStickParameters heightDescription) => MathUtil.IsZero(Denominator) ? 0 : (Numerator / Denominator);