当前位置: 首页>>代码示例>>C#>>正文


C# IQuantity.VerifyDimensions方法代码示例

本文整理汇总了C#中IQuantity.VerifyDimensions方法的典型用法代码示例。如果您正苦于以下问题:C# IQuantity.VerifyDimensions方法的具体用法?C# IQuantity.VerifyDimensions怎么用?C# IQuantity.VerifyDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQuantity的用法示例。


在下文中一共展示了IQuantity.VerifyDimensions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateRadiusFromDiameter

        /// <summary>
        /// 
        /// </summary>
        /// <param name="qty"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private static IQuantity CalculateRadiusFromDiameter(IQuantity qty, CircularCalculationType type)
        {
            if (!type.HasMask(CircularCalculationType.Diameter)) return null;

            // The dimension should be consistently Length, although the unit itself may be different.
            qty.VerifyDimensions(L.Meter);

            var resultQty = (Quantity) qty/2d;

            return resultQty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:17,代码来源:CircularCalculator.cs

示例2: CalculateAreaFromDiameter

        /// <summary>
        /// 
        /// </summary>
        /// <param name="qty"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private static IQuantity CalculateAreaFromDiameter(IQuantity qty, CircularCalculationType type)
        {
            if (!type.HasFlag(CircularCalculationType.Diameter)) return null;

            // The dimension should be consistently Length, although the unit itself may be different.
            qty.VerifyDimensions(L.Meter);

            var resultQty = (Quantity) ((Quantity) qty/2d).Squared()*Math.PI;

            return resultQty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:17,代码来源:CircularCalculator.cs

示例3: CalculateRadiusFromArea

        /// <summary>
        /// Returns the Radius calculated from the given <see cref="IArea"/> expressed through
        /// <paramref name="qty"/>. The resulting units will be in alignment with said Qty.
        /// </summary>
        /// <param name="qty"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        /// <a href="!:http://en.wikipedia.org/wiki/Arc_%28geometry%29" >Area (geometry)</a>
        private static IQuantity CalculateRadiusFromArea(IQuantity qty, CircularCalculationType type)
        {
            if (!type.HasMask(CircularCalculationType.Area)) return null;

            // Dimensions should be Length Squared. Does not matter the unit at this moment.
            qty.VerifyDimensions(L.Meter.Squared());

            var resultQty = ((Quantity) qty/Math.PI).SquareRoot();

            return resultQty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:19,代码来源:CircularCalculator.cs

示例4: CalculateRadiusFromCircumference

        /// <summary>
        /// 
        /// </summary>
        /// <param name="qty"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        /// <a href="!:http://en.wikipedia.org/wiki/Circumference" >Circumference</a>
        /// <a href="!:http://en.wikipedia.org/wiki/Pi" >Pi</a>
        private static IQuantity CalculateRadiusFromCircumference(IQuantity qty, CircularCalculationType type)
        {
            if (!type.HasMask(CircularCalculationType.Circumference)) return null;

            //TODO: for these types of calculations, it might make sense to capture a "derived" unit of "circumference", based on "length", but for first class treatment...
            qty.VerifyDimensions(L.Meter);

            var resultQty = (Quantity) qty/(2d*Math.PI);

            return resultQty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:19,代码来源:CircularCalculator.cs

示例5: CalculateEllipticalArea

        /// <summary>
        /// 
        /// </summary>
        /// <param name="aQty"></param>
        /// <param name="bQty"></param>
        /// <returns></returns>
        /// <a href="http://www.mathsisfun.com/geometry/ellipse.html" >Ellipse</a>
        /// <a href="http://mathworld.wolfram.com/Ellipse.html" >Ellipse</a>
        private static IQuantity CalculateEllipticalArea(IQuantity aQty, IQuantity bQty)
        {
            /* There is no such thing as types here, since by definition elliptical
             * area is calculated from A and B components, or major and minor axes. */

            {
                // The dimensions should be consistently Length, although the unit itself may be different.
                var m = L.Meter;
                aQty.VerifyDimensions(m);
                bQty.VerifyDimensions(m);
            }

            var resultQty = (Quantity) aQty*bQty*Math.PI;

            return resultQty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:24,代码来源:CircularCalculator.cs

示例6: CalculateDiameterFromRadius

        private static IQuantity CalculateDiameterFromRadius(IQuantity qty, CircularCalculationType type)
        {
            if (!type.HasFlag(CircularCalculationType.Radius)) return null;

            qty.VerifyDimensions(L.Meter);

            var resultQty = (Quantity) qty*2d;

            return resultQty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:10,代码来源:CircularCalculator.cs

示例7: Modulus

        private static IQuantity Modulus(IQuantity a, IQuantity b, Func<double, double, double> modulus,
            Func<IEnumerable<IDimension>, IEnumerable<IDimension>> dimensionality = null)
        {
            dimensionality = dimensionality ?? (x => x);

            var aBase = a.ToBase();
            var bBase = b.ToBase();

            //TODO: must B really be dimensionless? what are the ramifications for modulus being a close neighbor of division?
            // A can be any dimension, however, b must be dimensionless.
            b.VerifyDimensions();

            var aDims = aBase.Dimensions.EnumerateAll();

            return new Quantity(modulus(aBase.Value, bBase.Value),
                dimensionality(aDims).Reduce().ToArray());
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:17,代码来源:Quantity.cs

示例8: Add

 private static IQuantity Add(IQuantity a, double b, Func<double, double, double> adder)
 {
     a.VerifyDimensions();
     return new Quantity(adder(a.Value, b));
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:5,代码来源:Quantity.cs


注:本文中的IQuantity.VerifyDimensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。