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


C# IQuantity类代码示例

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


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


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