Пример #1
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            newtonpersquaremeter.CompareTo(new object());
        }
Пример #2
0
        /// <summary>
        /// Shrinking returns the <paramref name="values"/> as is when
        /// <see cref="Elasticity.Contraction"/> is not provided, in either the
        /// <paramref name="originalLength"/> or the given length, which ever is
        /// smallest. When <see cref="Elasticity.Contraction"/> is expected, discards all
        /// trailing false, or zero, bits from the collection. Maintains the assumption that the
        /// Most Significant Bits are the least important to keep when they are false, or zero.
        /// </summary>
        /// <param name="values"></param>
        /// <param name="originalLength"></param>
        /// <param name="elasticity"></param>
        /// <returns></returns>
        internal static IEnumerable <bool> Shrink(this IEnumerable <bool> values
                                                  , int originalLength, Elasticity elasticity)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            var valuesCount = values.Count();

            // ReSharper disable once InvertIf
            // Allowing for the Contraction use case...
            if (elasticity.Contains(Elasticity.Contraction))
            {
                var width = 0;

                // ReSharper disable once PossibleMultipleEnumeration
                while (width < valuesCount && !values.ElementAt(valuesCount - width - 1))
                {
                    width++;
                }

                // ReSharper disable once PossibleMultipleEnumeration
                return(values.Take(valuesCount - width));
            }

            // ReSharper disable once PossibleMultipleEnumeration
            return(values);
        }
Пример #3
0
        public void CompareToThrowsOnNull()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            newtonpersquaremeter.CompareTo(null);
        }
Пример #4
0
        public void EqualsIsImplemented()
        {
            Elasticity v = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.IsTrue(v.Equals(Elasticity.FromNewtonsPerSquareMeter(1)));
            Assert.IsFalse(v.Equals(Elasticity.Zero));
        }
Пример #5
0
        public void CompareToIsImplemented()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.AreEqual(0, newtonpersquaremeter.CompareTo(newtonpersquaremeter));
            Assert.Greater(newtonpersquaremeter.CompareTo(Elasticity.Zero), 0);
            Assert.Less(Elasticity.Zero.CompareTo(newtonpersquaremeter), 0);
        }
Пример #6
0
        internal ImmutableBitArrayFixture InternalShiftLeft(int count = 1, Elasticity elasticity = Elasticity.None)
        {
            var result = ShiftLeft(count, elasticity);

            Assert.NotNull(result);
            Assert.NotSame(this, result);
            return(new ImmutableBitArrayFixture(result));
        }
Пример #7
0
        /// <summary>
        /// Truncation returns the <paramref name="values"/> as is when
        /// <see cref="Elasticity.Expansion"/> is provided. Otherwise, we take what is there,
        /// or the <paramref name="originalLength"/> if necessary, which ever is smallest.
        /// </summary>
        /// <param name="values"></param>
        /// <param name="originalLength"></param>
        /// <param name="elasticity"></param>
        /// <returns></returns>
        internal static IEnumerable <bool> Truncate(this IEnumerable <bool> values
                                                    , int originalLength, Elasticity elasticity)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            var valuesCount = values.Count();

            return(elasticity.Contains(Elasticity.Expansion)
                   // ReSharper disable once PossibleMultipleEnumeration
                ? values
                   // ReSharper disable once PossibleMultipleEnumeration
                : values.Take(Math.Min(originalLength, valuesCount)));
        }
Пример #8
0
        public void ArithmeticOperators()
        {
            Elasticity v = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.AreEqual(-1, -v.NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(2, (Elasticity.FromNewtonsPerSquareMeter(3) - v).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(2, (v + v).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(10, (v * 10).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(10, (10 * v).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(2, (Elasticity.FromNewtonsPerSquareMeter(10) / 5).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(2, Elasticity.FromNewtonsPerSquareMeter(10) / Elasticity.FromNewtonsPerSquareMeter(5), NewtonsPerSquareMeterTolerance);
        }
Пример #9
0
        public void EqualityOperators()
        {
            Elasticity a = Elasticity.FromNewtonsPerSquareMeter(1);
            Elasticity b = Elasticity.FromNewtonsPerSquareMeter(2);

// ReSharper disable EqualExpressionComparison
            Assert.True(a == a);
            Assert.True(a != b);

            Assert.False(a == b);
            Assert.False(a != a);
// ReSharper restore EqualExpressionComparison
        }
Пример #10
0
        // TODO: TBD: consolidate the Set interface to the Elasticity one with default Elasticity...
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        /// <param name="value"></param>
        /// <param name="elasticity"></param>
        /// <inheritdoc />
        public void Set(int index, bool value, Elasticity elasticity)
        {
            if (elasticity.Contains(Elasticity.Expansion) &&
                index >= Length &&
                _bytes.Count < index / BitCount + 1)
            {
                _bytes.AddRange(new byte[index / BitCount + 1]);
                // TODO: TBD: or simply pass it through Length ?
                _length = index + 1;
            }

            Set(index, value);
        }
Пример #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Enabled.GetHashCode();
         hashCode = (hashCode * 397) ^ Density.GetHashCode();
         hashCode = (hashCode * 397) ^ Friction.GetHashCode();
         hashCode = (hashCode * 397) ^ Elasticity.GetHashCode();
         hashCode = (hashCode * 397) ^ FrictionWeight.GetHashCode();
         hashCode = (hashCode * 397) ^ ElasticityWeight.GetHashCode();
         return(hashCode);
     }
 }
Пример #12
0
        public void ComparisonOperators()
        {
            Elasticity oneNewtonPerSquareMeter  = Elasticity.FromNewtonsPerSquareMeter(1);
            Elasticity twoNewtonsPerSquareMeter = Elasticity.FromNewtonsPerSquareMeter(2);

            Assert.True(oneNewtonPerSquareMeter < twoNewtonsPerSquareMeter);
            Assert.True(oneNewtonPerSquareMeter <= twoNewtonsPerSquareMeter);
            Assert.True(twoNewtonsPerSquareMeter > oneNewtonPerSquareMeter);
            Assert.True(twoNewtonsPerSquareMeter >= oneNewtonPerSquareMeter);

            Assert.False(oneNewtonPerSquareMeter > twoNewtonsPerSquareMeter);
            Assert.False(oneNewtonPerSquareMeter >= twoNewtonsPerSquareMeter);
            Assert.False(twoNewtonsPerSquareMeter < oneNewtonPerSquareMeter);
            Assert.False(twoNewtonsPerSquareMeter <= oneNewtonPerSquareMeter);
        }
Пример #13
0
    public void Update()
    {
        if (this.oculusTouch.GetButton(this.button1) || this.oculusTouch.GetButton(this.button2))
        {
            //this.intersectionManager.Update();
            if (!this.HaveInterSections()) //this.intersectionManager.HaveInterSections())
            {
                Moebius moebius = new Moebius(newCurves);
                if (this.oculusTouch.GetButton(this.button1))
                {
                    moebius.Flow();
                }
                else if (this.oculusTouch.GetButton(this.button2))
                {
                    moebius.MomentumFlow();
                }

                foreach (Curve curve in this.newCurves)
                {
                    while (true)
                    {
                        Elasticity elasticity = new Elasticity(curve.points, curve.momentum, curve.segment);
                        if (elasticity.MaxError() < curve.segment * 0.2f)
                        {
                            break;
                        }
                        elasticity.Flow();
                    }
                }
            }
        }

        if (this.oculusTouch.GetButtonUp(this.button2))
        {
            foreach (Curve curve in this.newCurves)
            {
                curve.MomentumInitialize();
            }
        }

        foreach (Curve curve in this.newCurves)
        {
            curve.MeshUpdate();
            Graphics.DrawMesh(curve.mesh, Vector3.zero, Quaternion.identity, MakeMesh.SelectedCurveMaterial, 0);
        }
    }
Пример #14
0
        public void Execute(int index)
        {
            EntityPair entityPair = _springEntityPairs[index];
            Line       line       = _springLines[index];
            Elasticity elasticity = _springElasticities[index];

            float3 dist    = (line.P2 - line.P1);
            float  distMag = math.length(dist);
            float  refDist = elasticity.ReferenceLength;

            if (distMag > refDist)
            {
                float3 force = dist * (1 - refDist / distMag) * elasticity.YoungModulus;
                _hashMap.Add(entityPair.E1, force);
                _hashMap.Add(entityPair.E2, -force);
            }
        }
Пример #15
0
        /// <summary>
        /// Initializes the <see cref="Enumeration{TKey}.Key" /> in the <paramref name="values"/>.
        /// Assumes that the intended order of initialization has been resolved approaching a call
        /// to this helper method.
        /// </summary>
        /// <param name="values"></param>
        /// <param name="value"></param>
        /// <param name="shiftCount"></param>
        protected static void InitializeKeys(IEnumerable <T> values, uint value = 0x1, int shiftCount = 0)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            const Elasticity expansion = Elasticity.Expansion;

            var starting = ImmutableBitArray.FromInts(new[] { value }).ShiftLeft(shiftCount, expansion);

            values.ToList().Aggregate(starting, (key, x) =>
            {
                x.Key = key;
                return(key.ShiftLeft(elasticity: expansion));
            });
        }
Пример #16
0
        public void NewtonPerSquareMeterToElasticityUnits()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.AreEqual(AtmospheresInOneNewtonPerSquareMeter, newtonpersquaremeter.Atmospheres, AtmospheresTolerance);
            Assert.AreEqual(BarsInOneNewtonPerSquareMeter, newtonpersquaremeter.Bars, BarsTolerance);
            Assert.AreEqual(CentibarsInOneNewtonPerSquareMeter, newtonpersquaremeter.Centibars, CentibarsTolerance);
            Assert.AreEqual(DecapascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Decapascals, DecapascalsTolerance);
            Assert.AreEqual(DecibarsInOneNewtonPerSquareMeter, newtonpersquaremeter.Decibars, DecibarsTolerance);
            Assert.AreEqual(GigapascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Gigapascals, GigapascalsTolerance);
            Assert.AreEqual(HectopascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Hectopascals, HectopascalsTolerance);
            Assert.AreEqual(KilobarsInOneNewtonPerSquareMeter, newtonpersquaremeter.Kilobars, KilobarsTolerance);
            Assert.AreEqual(KilogramsForcePerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.KilogramsForcePerSquareCentimeter, KilogramsForcePerSquareCentimeterTolerance);
            Assert.AreEqual(KilogramsForcePerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.KilogramsForcePerSquareMeter, KilogramsForcePerSquareMeterTolerance);
            Assert.AreEqual(KilogramsForcePerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.KilogramsForcePerSquareMillimeter, KilogramsForcePerSquareMillimeterTolerance);
            Assert.AreEqual(KilonewtonsPerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.KilonewtonsPerSquareCentimeter, KilonewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(KilonewtonsPerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.KilonewtonsPerSquareMeter, KilonewtonsPerSquareMeterTolerance);
            Assert.AreEqual(KilonewtonsPerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.KilonewtonsPerSquareMillimeter, KilonewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(KilopascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Kilopascals, KilopascalsTolerance);
            Assert.AreEqual(KilopoundsForcePerSquareFootInOneNewtonPerSquareMeter, newtonpersquaremeter.KilopoundsForcePerSquareFoot, KilopoundsForcePerSquareFootTolerance);
            Assert.AreEqual(KilopoundsForcePerSquareInchInOneNewtonPerSquareMeter, newtonpersquaremeter.KilopoundsForcePerSquareInch, KilopoundsForcePerSquareInchTolerance);
            Assert.AreEqual(MegabarsInOneNewtonPerSquareMeter, newtonpersquaremeter.Megabars, MegabarsTolerance);
            Assert.AreEqual(MegapascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Megapascals, MegapascalsTolerance);
            Assert.AreEqual(MicropascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Micropascals, MicropascalsTolerance);
            Assert.AreEqual(MillibarsInOneNewtonPerSquareMeter, newtonpersquaremeter.Millibars, MillibarsTolerance);
            Assert.AreEqual(NewtonsPerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.NewtonsPerSquareCentimeter, NewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(NewtonsPerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(NewtonsPerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.NewtonsPerSquareMillimeter, NewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(PascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.Pascals, PascalsTolerance);
            Assert.AreEqual(PoundsForcePerSquareFootInOneNewtonPerSquareMeter, newtonpersquaremeter.PoundsForcePerSquareFoot, PoundsForcePerSquareFootTolerance);
            Assert.AreEqual(PoundsForcePerSquareInchInOneNewtonPerSquareMeter, newtonpersquaremeter.PoundsForcePerSquareInch, PoundsForcePerSquareInchTolerance);
            Assert.AreEqual(PsiInOneNewtonPerSquareMeter, newtonpersquaremeter.Psi, PsiTolerance);
            Assert.AreEqual(TechnicalAtmospheresInOneNewtonPerSquareMeter, newtonpersquaremeter.TechnicalAtmospheres, TechnicalAtmospheresTolerance);
            Assert.AreEqual(TonnesForcePerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.TonnesForcePerSquareCentimeter, TonnesForcePerSquareCentimeterTolerance);
            Assert.AreEqual(TonnesForcePerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.TonnesForcePerSquareMeter, TonnesForcePerSquareMeterTolerance);
            Assert.AreEqual(TonnesForcePerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.TonnesForcePerSquareMillimeter, TonnesForcePerSquareMillimeterTolerance);
            Assert.AreEqual(TorrsInOneNewtonPerSquareMeter, newtonpersquaremeter.Torrs, TorrsTolerance);
        }
Пример #17
0
        public void As()
        {
            var newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.AreEqual(AtmospheresInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Atmosphere), AtmospheresTolerance);
            Assert.AreEqual(BarsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Bar), BarsTolerance);
            Assert.AreEqual(CentibarsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Centibar), CentibarsTolerance);
            Assert.AreEqual(DecapascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Decapascal), DecapascalsTolerance);
            Assert.AreEqual(DecibarsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Decibar), DecibarsTolerance);
            Assert.AreEqual(GigapascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Gigapascal), GigapascalsTolerance);
            Assert.AreEqual(HectopascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Hectopascal), HectopascalsTolerance);
            Assert.AreEqual(KilobarsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Kilobar), KilobarsTolerance);
            Assert.AreEqual(KilogramsForcePerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilogramForcePerSquareCentimeter), KilogramsForcePerSquareCentimeterTolerance);
            Assert.AreEqual(KilogramsForcePerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilogramForcePerSquareMeter), KilogramsForcePerSquareMeterTolerance);
            Assert.AreEqual(KilogramsForcePerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilogramForcePerSquareMillimeter), KilogramsForcePerSquareMillimeterTolerance);
            Assert.AreEqual(KilonewtonsPerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilonewtonPerSquareCentimeter), KilonewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(KilonewtonsPerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilonewtonPerSquareMeter), KilonewtonsPerSquareMeterTolerance);
            Assert.AreEqual(KilonewtonsPerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilonewtonPerSquareMillimeter), KilonewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(KilopascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Kilopascal), KilopascalsTolerance);
            Assert.AreEqual(KilopoundsForcePerSquareFootInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilopoundForcePerSquareFoot), KilopoundsForcePerSquareFootTolerance);
            Assert.AreEqual(KilopoundsForcePerSquareInchInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.KilopoundForcePerSquareInch), KilopoundsForcePerSquareInchTolerance);
            Assert.AreEqual(MegabarsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Megabar), MegabarsTolerance);
            Assert.AreEqual(MegapascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Megapascal), MegapascalsTolerance);
            Assert.AreEqual(MicropascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Micropascal), MicropascalsTolerance);
            Assert.AreEqual(MillibarsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Millibar), MillibarsTolerance);
            Assert.AreEqual(NewtonsPerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.NewtonPerSquareCentimeter), NewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(NewtonsPerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.NewtonPerSquareMeter), NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(NewtonsPerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.NewtonPerSquareMillimeter), NewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(PascalsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Pascal), PascalsTolerance);
            Assert.AreEqual(PoundsForcePerSquareFootInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.PoundForcePerSquareFoot), PoundsForcePerSquareFootTolerance);
            Assert.AreEqual(PoundsForcePerSquareInchInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.PoundForcePerSquareInch), PoundsForcePerSquareInchTolerance);
            Assert.AreEqual(PsiInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Psi), PsiTolerance);
            Assert.AreEqual(TechnicalAtmospheresInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.TechnicalAtmosphere), TechnicalAtmospheresTolerance);
            Assert.AreEqual(TonnesForcePerSquareCentimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.TonneForcePerSquareCentimeter), TonnesForcePerSquareCentimeterTolerance);
            Assert.AreEqual(TonnesForcePerSquareMeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.TonneForcePerSquareMeter), TonnesForcePerSquareMeterTolerance);
            Assert.AreEqual(TonnesForcePerSquareMillimeterInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.TonneForcePerSquareMillimeter), TonnesForcePerSquareMillimeterTolerance);
            Assert.AreEqual(TorrsInOneNewtonPerSquareMeter, newtonpersquaremeter.As(ElasticityUnit.Torr), TorrsTolerance);
        }
Пример #18
0
        public void ConversionRoundTrip()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.AreEqual(1, Elasticity.FromAtmospheres(newtonpersquaremeter.Atmospheres).NewtonsPerSquareMeter, AtmospheresTolerance);
            Assert.AreEqual(1, Elasticity.FromBars(newtonpersquaremeter.Bars).NewtonsPerSquareMeter, BarsTolerance);
            Assert.AreEqual(1, Elasticity.FromCentibars(newtonpersquaremeter.Centibars).NewtonsPerSquareMeter, CentibarsTolerance);
            Assert.AreEqual(1, Elasticity.FromDecapascals(newtonpersquaremeter.Decapascals).NewtonsPerSquareMeter, DecapascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromDecibars(newtonpersquaremeter.Decibars).NewtonsPerSquareMeter, DecibarsTolerance);
            Assert.AreEqual(1, Elasticity.FromGigapascals(newtonpersquaremeter.Gigapascals).NewtonsPerSquareMeter, GigapascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromHectopascals(newtonpersquaremeter.Hectopascals).NewtonsPerSquareMeter, HectopascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromKilobars(newtonpersquaremeter.Kilobars).NewtonsPerSquareMeter, KilobarsTolerance);
            Assert.AreEqual(1, Elasticity.FromKilogramsForcePerSquareCentimeter(newtonpersquaremeter.KilogramsForcePerSquareCentimeter).NewtonsPerSquareMeter, KilogramsForcePerSquareCentimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromKilogramsForcePerSquareMeter(newtonpersquaremeter.KilogramsForcePerSquareMeter).NewtonsPerSquareMeter, KilogramsForcePerSquareMeterTolerance);
            Assert.AreEqual(1, Elasticity.FromKilogramsForcePerSquareMillimeter(newtonpersquaremeter.KilogramsForcePerSquareMillimeter).NewtonsPerSquareMeter, KilogramsForcePerSquareMillimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromKilonewtonsPerSquareCentimeter(newtonpersquaremeter.KilonewtonsPerSquareCentimeter).NewtonsPerSquareMeter, KilonewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromKilonewtonsPerSquareMeter(newtonpersquaremeter.KilonewtonsPerSquareMeter).NewtonsPerSquareMeter, KilonewtonsPerSquareMeterTolerance);
            Assert.AreEqual(1, Elasticity.FromKilonewtonsPerSquareMillimeter(newtonpersquaremeter.KilonewtonsPerSquareMillimeter).NewtonsPerSquareMeter, KilonewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromKilopascals(newtonpersquaremeter.Kilopascals).NewtonsPerSquareMeter, KilopascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromKilopoundsForcePerSquareFoot(newtonpersquaremeter.KilopoundsForcePerSquareFoot).NewtonsPerSquareMeter, KilopoundsForcePerSquareFootTolerance);
            Assert.AreEqual(1, Elasticity.FromKilopoundsForcePerSquareInch(newtonpersquaremeter.KilopoundsForcePerSquareInch).NewtonsPerSquareMeter, KilopoundsForcePerSquareInchTolerance);
            Assert.AreEqual(1, Elasticity.FromMegabars(newtonpersquaremeter.Megabars).NewtonsPerSquareMeter, MegabarsTolerance);
            Assert.AreEqual(1, Elasticity.FromMegapascals(newtonpersquaremeter.Megapascals).NewtonsPerSquareMeter, MegapascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromMicropascals(newtonpersquaremeter.Micropascals).NewtonsPerSquareMeter, MicropascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromMillibars(newtonpersquaremeter.Millibars).NewtonsPerSquareMeter, MillibarsTolerance);
            Assert.AreEqual(1, Elasticity.FromNewtonsPerSquareCentimeter(newtonpersquaremeter.NewtonsPerSquareCentimeter).NewtonsPerSquareMeter, NewtonsPerSquareCentimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromNewtonsPerSquareMeter(newtonpersquaremeter.NewtonsPerSquareMeter).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
            Assert.AreEqual(1, Elasticity.FromNewtonsPerSquareMillimeter(newtonpersquaremeter.NewtonsPerSquareMillimeter).NewtonsPerSquareMeter, NewtonsPerSquareMillimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromPascals(newtonpersquaremeter.Pascals).NewtonsPerSquareMeter, PascalsTolerance);
            Assert.AreEqual(1, Elasticity.FromPoundsForcePerSquareFoot(newtonpersquaremeter.PoundsForcePerSquareFoot).NewtonsPerSquareMeter, PoundsForcePerSquareFootTolerance);
            Assert.AreEqual(1, Elasticity.FromPoundsForcePerSquareInch(newtonpersquaremeter.PoundsForcePerSquareInch).NewtonsPerSquareMeter, PoundsForcePerSquareInchTolerance);
            Assert.AreEqual(1, Elasticity.FromPsi(newtonpersquaremeter.Psi).NewtonsPerSquareMeter, PsiTolerance);
            Assert.AreEqual(1, Elasticity.FromTechnicalAtmospheres(newtonpersquaremeter.TechnicalAtmospheres).NewtonsPerSquareMeter, TechnicalAtmospheresTolerance);
            Assert.AreEqual(1, Elasticity.FromTonnesForcePerSquareCentimeter(newtonpersquaremeter.TonnesForcePerSquareCentimeter).NewtonsPerSquareMeter, TonnesForcePerSquareCentimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromTonnesForcePerSquareMeter(newtonpersquaremeter.TonnesForcePerSquareMeter).NewtonsPerSquareMeter, TonnesForcePerSquareMeterTolerance);
            Assert.AreEqual(1, Elasticity.FromTonnesForcePerSquareMillimeter(newtonpersquaremeter.TonnesForcePerSquareMillimeter).NewtonsPerSquareMeter, TonnesForcePerSquareMillimeterTolerance);
            Assert.AreEqual(1, Elasticity.FromTorrs(newtonpersquaremeter.Torrs).NewtonsPerSquareMeter, TorrsTolerance);
        }
Пример #19
0
 public void FromValueAndUnit()
 {
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Atmosphere).Atmospheres, AtmospheresTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Bar).Bars, BarsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Centibar).Centibars, CentibarsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Decapascal).Decapascals, DecapascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Decibar).Decibars, DecibarsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Gigapascal).Gigapascals, GigapascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Hectopascal).Hectopascals, HectopascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Kilobar).Kilobars, KilobarsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilogramForcePerSquareCentimeter).KilogramsForcePerSquareCentimeter, KilogramsForcePerSquareCentimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilogramForcePerSquareMeter).KilogramsForcePerSquareMeter, KilogramsForcePerSquareMeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilogramForcePerSquareMillimeter).KilogramsForcePerSquareMillimeter, KilogramsForcePerSquareMillimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilonewtonPerSquareCentimeter).KilonewtonsPerSquareCentimeter, KilonewtonsPerSquareCentimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilonewtonPerSquareMeter).KilonewtonsPerSquareMeter, KilonewtonsPerSquareMeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilonewtonPerSquareMillimeter).KilonewtonsPerSquareMillimeter, KilonewtonsPerSquareMillimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Kilopascal).Kilopascals, KilopascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilopoundForcePerSquareFoot).KilopoundsForcePerSquareFoot, KilopoundsForcePerSquareFootTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.KilopoundForcePerSquareInch).KilopoundsForcePerSquareInch, KilopoundsForcePerSquareInchTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Megabar).Megabars, MegabarsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Megapascal).Megapascals, MegapascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Micropascal).Micropascals, MicropascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Millibar).Millibars, MillibarsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.NewtonPerSquareCentimeter).NewtonsPerSquareCentimeter, NewtonsPerSquareCentimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.NewtonPerSquareMeter).NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.NewtonPerSquareMillimeter).NewtonsPerSquareMillimeter, NewtonsPerSquareMillimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Pascal).Pascals, PascalsTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.PoundForcePerSquareFoot).PoundsForcePerSquareFoot, PoundsForcePerSquareFootTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.PoundForcePerSquareInch).PoundsForcePerSquareInch, PoundsForcePerSquareInchTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Psi).Psi, PsiTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.TechnicalAtmosphere).TechnicalAtmospheres, TechnicalAtmospheresTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.TonneForcePerSquareCentimeter).TonnesForcePerSquareCentimeter, TonnesForcePerSquareCentimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.TonneForcePerSquareMeter).TonnesForcePerSquareMeter, TonnesForcePerSquareMeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.TonneForcePerSquareMillimeter).TonnesForcePerSquareMillimeter, TonnesForcePerSquareMillimeterTolerance);
     Assert.AreEqual(1, Elasticity.From(1, ElasticityUnit.Torr).Torrs, TorrsTolerance);
 }
Пример #20
0
 /// <summary>
 /// Returns whether <paramref name="value"/> Contains the <paramref name="mask"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="mask"></param>
 /// <returns></returns>
 public static bool Contains(this Elasticity?value, Elasticity mask)
 => value.HasValue && (value & mask) == mask;
Пример #21
0
 // TODO: TBD: ditto Elastic Set / capture this interface as well...
 /// <inheritdoc />
 public bool Get(int index, Elasticity elasticity)
 // TODO: TBD: what to do in the use case for Expansion ...
 => (elasticity.Contains(Elasticity.Expansion) || index < Length) && Get(index);
Пример #22
0
 public bool Equals(PhysicalProperties other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Enabled == other.Enabled && Density.Equals(other.Density) && Friction.Equals(other.Friction) && Elasticity.Equals(other.Elasticity) && FrictionWeight.Equals(other.FrictionWeight) && ElasticityWeight.Equals(other.ElasticityWeight));
 }
Пример #23
0
        public void EqualsReturnsFalseOnNull()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.IsFalse(newtonpersquaremeter.Equals(null));
        }
Пример #24
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Elasticity newtonpersquaremeter = Elasticity.FromNewtonsPerSquareMeter(1);

            Assert.IsFalse(newtonpersquaremeter.Equals(new object()));
        }
Пример #25
0
 /// <summary>
 /// Returns whether <paramref name="value"/> Contains the <paramref name="mask"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="mask"></param>
 /// <returns></returns>
 public static bool Contains(this Elasticity value, Elasticity mask)
 => (value & mask) == mask;