Ejemplo n.º 1
0
            public static MeasureUnit Auto(MeasureUnit force, MeasureUnit length)
            {
                #region force=[N]
                if (force.Equals(Force.N))
                {
                    if (length.Equals(Length.m))
                    {
                        return(Pa);
                    }
                }
                #endregion

                #region force=[kN]
                else if (force.Equals(Force.kN))
                {
                    if (length.Equals(Length.m))
                    {
                        return(Pressure.kPa);
                    }
                    if (length.Equals(Length.mm))
                    {
                        return(Pressure.GPa);
                    }
                }
                #endregion

                throw new NotImplementedException($"pressure mu automatic not defined for input force=[{force.Name}] and length=[{length.Name}]");
            }
Ejemplo n.º 2
0
            /// <summary>
            /// retrieve m/s2 when length=m and time=s
            /// </summary>
            public static MeasureUnit Auto(MeasureUnit length, MeasureUnit time)
            {
                if (length.Equals(Length.m) && time.Equals(Time.sec))
                {
                    return(m_s2);
                }
                if (length.Equals(Length.mm) && time.Equals(Time.sec))
                {
                    return(mm_s2);
                }

                throw new Exception($"undefined auto Acceleration for unit length=[{length}] time=[{time}]");
            }
Ejemplo n.º 3
0
            public static MeasureUnit Auto(MeasureUnit planeAngle, MeasureUnit time)
            {
                if (planeAngle.Equals(PlaneAngle.rad) && time.Equals(Time.sec))
                {
                    return(rad_s2);
                }
                if (planeAngle.Equals(PlaneAngle.deg) && time.Equals(Time.sec))
                {
                    return(deg_s2);
                }

                throw new NotImplementedException($"AngularAcceleration mu automatic not defined for input planeAngle=[{planeAngle.Name}] and time=[{time.Name}]");
            }
Ejemplo n.º 4
0
        /// <summary>
        /// Convert measure units beetween two compatible units
        /// </summary>
        /// <param name="fromUnit">The measure unit to be converted</param>
        /// <param name="toUnit">The target measure unit</param>
        /// <returns>The equivalent ratio between two measure units</returns>
        public static decimal GetEquivalentUnit(MeasureUnit fromUnit, MeasureUnit toUnit)
        {
            IList <MeasureUnit> massUnits = new List <MeasureUnit>()
            {
                MeasureUnit.KILOGRAM, MeasureUnit.GRAM, MeasureUnit.POUND, MeasureUnit.OUNCE
            };
            IList <MeasureUnit> volumeUnits = new List <MeasureUnit>()
            {
                MeasureUnit.LITER, MeasureUnit.MILLILITER, MeasureUnit.GALLON
            };

            if (fromUnit.Equals(toUnit))
            {
                return(1);
            }

            if (massUnits.Contains(fromUnit) && massUnits.Contains(toUnit))
            {
                // mass conversion
                return(GetMassConversion(fromUnit, toUnit));
            }

            if (volumeUnits.Contains(fromUnit) && volumeUnits.Contains(toUnit))
            {
                // volume conversion
                return(GetVolumeConversion(fromUnit, toUnit));
            }

            throw new Exception("Measurement units not compatible");
        }
Ejemplo n.º 5
0
            /// <summary>
            /// retrieve Nm when input force=N, length=m etc
            /// </summary>
            public static MeasureUnit Auto(MeasureUnit force, MeasureUnit length)
            {
                if (force.Equals(Force.N) && length.Equals(Length.m))
                {
                    return(Nm);
                }
                if (force.Equals(Force.kN) && length.Equals(Length.m))
                {
                    return(kNm);
                }
                if (force.Equals(Force.N) && length.Equals(Length.mm))
                {
                    return(Nmm);
                }

                throw new Exception($"undefined auto BendingMoment for unit force=[{force}] length=[{length}]");
            }
Ejemplo n.º 6
0
            /// <summary>
            /// retrieve mm2 when input length=mm, etc
            /// </summary>
            public static MeasureUnit Auto(MeasureUnit length)
            {
                if (length.Equals(Length.mm))
                {
                    return(mm2);
                }
                if (length.Equals(Length.cm))
                {
                    return(cm2);
                }
                if (length.Equals(Length.m))
                {
                    return(m2);
                }
                if (length.Equals(Length.inch))
                {
                    return(inch2);
                }

                throw new Exception($"undefined auto Length for unit [{length}]");
            }