• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IQuantity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CalculateCircumference

 /// <summary>
 /// 
 /// </summary>
 /// <param name="qty"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public IQuantity CalculateCircumference(IQuantity qty,
     CircularCalculationType type = CircularCalculationType.Diameter)
 {
     return VerifyDimensions(
         CalculateCircumferenceFromRadius(qty, type)
         ?? CalculateCircumferenceFromDiameter(qty, type), L.Meter);
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:13,代码来源:CircularCalculator.cs


示例2: CalculateAngleBeta

        /// <summary>
        /// Returns the calculated angle Beta, ß, given any two of <paramref name="aQty"/>,
        /// <paramref name="bQty"/>, or <paramref name="cQty"/>. If all three are provided, then
        /// the first two are selected. If one or none are provided, then an exception is thrown.
        /// </summary>
        /// <param name="aQty"></param>
        /// <param name="bQty"></param>
        /// <param name="cQty"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public IQuantity CalculateAngleBeta(IQuantity aQty = null,
            IQuantity bQty = null, IQuantity cQty = null)
        {
            VerifyAngleCalculationTriangleSides(aQty, bQty, cQty);

            var m = L.Meter;
            IQuantity betaQty = null;

            if (AreNotNull(aQty, bQty))
            {
                var a = VerifyDimensions(aQty, m);
                var b = VerifyDimensions(bQty, m);
                betaQty = ((Quantity) b/a).Atan();
            }

            if (AreNotNull(aQty, cQty))
            {
                var a = VerifyDimensions(aQty, m);
                var c = VerifyDimensions(cQty, m);
                betaQty = ((Quantity) a/c).Acos();
            }

            if (AreNotNull(bQty, cQty))
            {
                var b = VerifyDimensions(bQty, m);
                var c = VerifyDimensions(cQty, m);
                betaQty = ((Quantity) b/c).Asin();
            }

            var rad = Theta.Radian;

            return VerifyDimensions(betaQty, rad);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:43,代码来源:RightTriangleCalculator.cs


示例3: CalculateArea

 /// <summary>
 /// Returns the calculated Area given the <paramref name="qty"/>.
 /// </summary>
 /// <param name="qty"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public IQuantity CalculateArea(IQuantity qty,
     CircularCalculationType type = CircularCalculationType.Diameter)
 {
     return VerifyDimensions(
         CalculateAreaFromRadius(qty, type)
         ?? CalculateAreaFromDiameter(qty, type), A.SquareMeter);
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:13,代码来源:CircularCalculator.cs


示例4: Calculate

        /// <summary>
        /// Calculates the trajectory components at the specified <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public IDictionary<TrajectoryComponent, IQuantity> Calculate(IQuantity timeQty)
        {
            IDictionary<TrajectoryComponent, IQuantity> results;

            TryCalculate(timeQty, out results);

            return results;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:13,代码来源:TrajectoryCalculator.cs


示例5: Quantity

		/// <summary>
		/// Copy constructor
		/// </summary>
		/// <param name="source">The quantity to copy</param>
		public Quantity(IQuantity source)
		{
			Description = source.Description;
			Dimension = source.Dimension;
			ID = source.ID;
			Unit = source.Unit;
			ValueType = source.ValueType;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:12,代码来源:Quantity.cs


示例6: TrajectoryParameters

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ilhQty">An initial launch height quantity.</param>
 /// <param name="vlaQty">A vertical launch angle quantity.</param>
 /// <param name="hlaQty">A horizontal launch angle quantity.</param>
 /// <param name="ivQty">An initial velocity quantity.</param>
 public TrajectoryParameters(IQuantity ilhQty, IQuantity vlaQty, IQuantity hlaQty, IQuantity ivQty)
 {
     InitialLaunchHeightQty = ilhQty;
     VerticalLaunchAngleQty = vlaQty;
     HorizontalLaunchAngleQty = hlaQty;
     InitialVelocityQty = ivQty;
     PreviousTimeQty = null;
     TimeQty = null;
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:16,代码来源:TrajectoryParameters.cs


示例7: AtmosphericTrajectoryParameters

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ilhQty"></param>
 /// <param name="vlaQty"></param>
 /// <param name="hlaQty"></param>
 /// <param name="ivQty"></param>
 /// <param name="projectileMassQty"></param>
 /// <param name="projectileAreaQty"></param>
 /// <param name="rhoQty">An air density (&#961;, rho) quantity.</param>
 /// <param name="cdQty"></param>
 public AtmosphericTrajectoryParameters(IQuantity ilhQty, IQuantity vlaQty, IQuantity hlaQty,
     IQuantity ivQty, IQuantity projectileMassQty, IQuantity projectileAreaQty, IQuantity rhoQty,
     IQuantity cdQty)
     : base(ilhQty, vlaQty, hlaQty, ivQty)
 {
     ProjectileMassQty = projectileMassQty;
     ProjectileAreaQty = projectileAreaQty;
     AirDensityQty = rhoQty;
     DragCoefficientQty = cdQty;
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:21,代码来源:AtmosphericTrajectoryParameters.cs


示例8: Execute

        /// <summary>
        /// Executes the operation.
        /// </summary>
        /// <param name="lhs">The LHS quantity.</param>
        /// <param name="rhs">The RHS quantity.</param>
        /// <returns>
        /// The resulting value.
        /// </returns>
        public double Execute(IQuantity lhs, IUnit rhs)
        {
            var valueUnit = lhs.Unit;
            var value = lhs.Value;
            if (!UnitHelper.AreUnitsEqual(valueUnit, rhs))
            {
                value = rhs.FromBase(valueUnit.ToBase(value));
            }

            return value;
        }
开发者ID:hugener,项目名称:Sundew.Quantities,代码行数:19,代码来源:ConvertToUnitOperation.cs


示例9: Calculate

        /// <summary>
        /// Calculates the <see cref="TrajectoryComponent.MaxHeight"/> component. Effectively
        /// ignores the <paramref name="timeQty"/> part, for purposes of this component.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, V.MetersPerSecond);

            var g = Values.G;

            // http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra5
            var resultQty = (Quantity) ivv.Squared()/((Quantity) g*2d);

            return VerifyDimensions(resultQty, L.Meter);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:18,代码来源:BasicMaximumHeightComponentCalculator.cs


示例10: Calculate

        /// <summary>
        /// Calculates the <see cref="TrajectoryComponent.MaxTime"/> component. Effectively
        /// ignores the <paramref name="timeQty"/> part, for purposes of this component.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            // ReSharper disable once InvertIf
            if (ReferenceEquals(null, _componentQty))
            {
                var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, V.MetersPerSecond);
                var vla = VerifyDimensions(parameters.VerticalLaunchAngleQty, Theta.Radian);

                var g = Values.G;

                _componentQty = (2d*(Quantity) ivv*vla.Sin())/g;
            }

            return VerifyDimensions(_componentQty, T.Second);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:22,代码来源:BasicMaximumTimeComponentCalculator.cs


示例11: VerifyDimensions

        /// <summary>
        /// Returns the <paramref name="qty"/> with verified <paramref name="dimensions"/>.
        /// </summary>
        /// <param name="qty"></param>
        /// <param name="dimensions"></param>
        /// <returns></returns>
        protected static IQuantity VerifyDimensions(IQuantity qty, params IDimension[] dimensions)
        {
            if (ReferenceEquals(null, qty))
                throw new ArgumentNullException("qty", "qty instance is expected.");

            // ReSharper disable once InvertIf
            if (!qty.Dimensions.AreCompatible(dimensions, true))
            {
                var message = string.Format("qty force dimensions incorrect expected: {{{0}}} but was: {{{1}}}",
                    string.Join(" ", from x in dimensions select x.ToString()), qty);
                throw new ArgumentException(message, "qty");
            }

            return qty;
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:21,代码来源:CalculatorBase.cs


示例12: Calculate

        /// <summary>
        /// calculates air density, ρ (rho), given <paramref name="absolutePressureQty">absolute pressure,
        /// p</paramref>, <paramref name="dryAirSpecificGasConstantQty">specific gas constant for dry air,
        /// R<sub>specific</sub></paramref>, and <paramref name="temperatureQty">absolute temperature,
        /// K</paramref>.
        /// </summary>
        /// <param name="absolutePressureQty"></param>
        /// <param name="dryAirSpecificGasConstantQty"></param>
        /// <param name="temperatureQty"></param>
        /// <returns></returns>
        /// <a href="!:http://en.wikipedia.org/wiki/Density_of_air#Temperature_and_pressure" >Density of air,
        /// Temperature and pressure</a>
        public IQuantity Calculate(IQuantity absolutePressureQty,
            IQuantity dryAirSpecificGasConstantQty,
            IQuantity temperatureQty)
        {
            var kg = M.Kilogram;
            // ReSharper disable InconsistentNaming
            var K = Theta.Kelvin;

            var p = VerifyDimensions(absolutePressureQty, P.Pascal);

            var Rspecific = VerifyDimensions(dryAirSpecificGasConstantQty, E.Joule, kg.Invert(), K.Invert());

            var T = VerifyDimensions(temperatureQty, K);

            return VerifyDimensions((Quantity) p/((Quantity) Rspecific*T), kg, L.Meter.Cubed().Invert());
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:28,代码来源:AirDensityCalculator.cs


示例13:

        string IQuantityFormatter.Format(IQuantity quantity)
        {
            if (quantity == null)
            {
                return string.Empty;
            }

            if (!(quantity is Acceleration))
            {
                return "wrong type";
            }

            var qty = (Acceleration)quantity;
            var culture = NumericBox.GetCulture(this);
            return qty.ToString(this.Unit, this.SymbolFormat, culture);
        }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.PropertyGrid,代码行数:16,代码来源:UnitRow.generated.cs


示例14: Calculate

        /// <summary>
        /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var m = L.Meter;
            var s = T.Second;

            var t = VerifyDimensions(timeQty, s);

            var ihv = VerifyDimensions(parameters.InitialHorizontalVelocityQty, m, s.Invert());

            /* x = ( V cos A ) t
             * Ditto re: vertical component calculations: we already have initial horizontal velocity ready.
             * This calculation intentionally ignores Forces due to aerodynamic drag. */
            var resultQty = (Quantity) ihv*t;

            // Should be left with a Length dimension.
            return VerifyDimensions(resultQty, m);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:23,代码来源:BasicHorizontalComponentCalculator.cs


示例15: Calculate

        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            // ReSharper disable once InvertIf
            if (ReferenceEquals(null, _componentQty))
            {
                var iv = VerifyDimensions(parameters.InitialVelocityQty, V.MetersPerSecond);
                var vla = VerifyDimensions(parameters.VerticalLaunchAngleQty, Theta.Radian);

                var g = Values.G;

                //TODO: also does not take into consideration the initial launch height, i.e. from which thrown, punted, etc.

                // Also, leverages trig identity: sin( 2 Θ ) = 2 sin( Θ ) cos( Θ )
                _componentQty = ((Quantity) iv.Squared()*((Quantity) vla*2d).Sin())/g;
            }

            return VerifyDimensions(_componentQty, L.Meter);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:18,代码来源:BasicMaximumRangeComponentCalculator.cs


示例16: Calculate

        /// <summary>
        /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var m = L.Meter;
            var s = T.Second;

            var t = VerifyDimensions(timeQty, s);

            var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, m, s.Invert());

            // TODO: TBD: Forces due to aerodynamic lift must also play a role here, but not in this "simple" component calculator...
            var g = VerifyDimensions(Values.StandardGravity, m, s.Squared().Invert());

            /* y = ( V sin A ) t - g t^2 / 2
             * Or in this case, we have already calculated the initial vertical velocity component.
             * ref: http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra12 */
            var resultQty = (Quantity) ivv*t - ((Quantity) g*t.Squared())/2d;

            // Should be left with a Length dimension.
            return VerifyDimensions(resultQty, m);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:26,代码来源:BasicVerticalComponentCalculator.cs


示例17: GetMathML

        /// <summary>
        /// Gets the math ml.
        /// </summary>
        /// <param name="quantity">The quantity.</param>
        /// <param name="unitFormat">The unit format.</param>
        /// <param name="multiplicationSign">The multiplication sign.</param>
        /// <returns>The root <see cref="XElement"/> node.</returns>
        public XElement GetMathML(
            IQuantity quantity,
            UnitFormat unitFormat = UnitFormat.Default,
            MultiplicationSign multiplicationSign = MultiplicationSign.Invisible)
        {
            var mn = new XElement(MathML.Mn, quantity.Value);
            var mrow = new XElement(MathML.Mrow, mn);
            var unitElement = mrow;
            if (unitFormat.HasFlag(UnitFormat.SurroundInBrackets))
            {
                var mfenced = new XElement(MathML.Mfenced, MathML.OpenLeftBracket, MathML.CloseRightBrack);
                mrow.Add(mfenced);
                unitElement = mfenced;
            }

            ExpressionToMathMLVisitor.DefaultMathMLVisitor.Visit(
                quantity.Unit.GetExpression(),
                multiplicationSign,
                unitElement);
            return new XElement(MathML.Math, new XAttribute(MathML.NamespaceAlias, MathML.Namespace), mrow);
        }
开发者ID:hugener,项目名称:Sundew.Quantities,代码行数:28,代码来源:QuantityToMathMLConverter.cs


示例18: CheckInfinity

        private static Constraint CheckInfinity(IQuantity qty)
        {
            var result = double.IsPositiveInfinity(qty.Value)
                ? Is.EqualTo(double.PositiveInfinity)
                : null;

            return result ?? (double.IsNegativeInfinity(qty.Value)
                ? Is.EqualTo(double.NegativeInfinity)
                : null);
        }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:10,代码来源:TrigonometryContext.cs


示例19: Function

 public ITrigonometryContext Function(Func<IQuantity, IQuantity> function)
 {
     Assert.That(function, Is.Not.Null);
     _actualQty = function(_startingPart.Qty);
     return this;
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:6,代码来源:TrigonometryContext.cs


示例20: CheckValue

 private Constraint CheckValue(IQuantity qty)
 {
     return HasEpsilon
         ? Is.EqualTo(qty.Value).Within(Epsilon)
         : Is.EqualTo(qty.Value);
 }
开发者ID:mwpowellhtx,项目名称:clockworks,代码行数:6,代码来源:TrigonometryContext.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IQuery类代码示例发布时间:2022-05-24
下一篇:
C# IQGraphicsItem类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap