Beispiel #1
0
        public Unit Reciprocal()
        {
            var t1 = new UnitTerm(this, -1);
            var t  = new UnitTerms {
                t1
            };
            var a = new DerivedUnit(t);
            var b = (BaseMeasure)this.measure;

            a.Measure = b.Reciprocal();
            return(a);
        }
Beispiel #2
0
        public Unit Multiply(BaseUnit i, bool isDivide = false)
        {
            var t1 = new UnitTerm(this, 1);
            var t2 = isDivide ? new UnitTerm(i, -1) : new UnitTerm(i, 1);
            var t  = new UnitTerms {
                t1, t2
            };
            var a = new DerivedUnit(t);
            var b = (BaseMeasure)measure;

            a.Measure = isDivide ? b.Multiply((BaseMeasure)i.Measure, true): b.Multiply(i.Measure);
            return(a);
        }
Beispiel #3
0
        public Unit Multiply(DerivedUnit m)
        {
            var t = new UnitTerms();

            t.Add(new UnitTerm(this, 1));
            foreach (var e in m.Terms)
            {
                t.Add(new UnitTerm(e.Unit as BaseUnit, e.Power));
            }
            var a = new DerivedUnit(t);
            var b = (BaseMeasure)measure;

            a.Measure = b.Multiply((DerivedMeasure)m.Measure);
            return(a);
        }
Beispiel #4
0
        public Unit Reciprocal()
        {
            var a = new UnitTerms();

            foreach (var e in Terms)
            {
                var c = Clone(e);
                c.Power = c.Power * -1;
                a.Add(c);
            }
            var b = new DerivedUnit(a);
            var d = (DerivedMeasure)measure;

            b.measure = d.Reciprocal();
            return(b);
        }
Beispiel #5
0
        public Unit Reciprocal()
        {
            var a = new UnitTerms();

            foreach (var e in Terms)
            {
                var c = new UnitTerm {
                    Unit = e.Unit, Power = e.Power
                };
                c.Power *= -1;
                a.Add(c);
            }
            var b = new DerivedUnit(a);
            var d = (DerivedMeasure)measure;

            b.measure = d.Reciprocal();
            return(b);
        }
Beispiel #6
0
        public Unit Exponentiation(int i)
        {
            if (i == 0)
            {
                return(new BaseUnit());
            }
            UnitTerm t1;

            t1 = new UnitTerm(this, i);
            var t = new UnitTerms {
                t1
            };
            var a = new DerivedUnit(t);
            var b = (BaseMeasure)this.measure;

            a.Measure = b.Exponentiation(i);
            a.Factor  = Math.Pow(Factor, i);
            Measures.Instance.Add(a.Measure);
            return(a);
        }
Beispiel #7
0
        public Unit Exponentiation(int i)
        {
            if (i == 0)
            {
                return(Empty);
            }
            var a = new UnitTerms();

            foreach (var e in Terms)
            {
                var c = Clone(e);
                c.Power = c.Power * i;
                a.Add(c);
            }
            var b = new DerivedUnit(a);
            var d = (DerivedMeasure)this.measure;

            b.measure = d.Exponentiation(i);
            return(b);
        }
Beispiel #8
0
        public Unit Exponentiation(int i)
        {
            if (i == 0)
            {
                return(new BaseUnit());
            }
            var a = new UnitTerms();

            foreach (var e in Terms)
            {
                var c = new UnitTerm {
                    Unit = e.Unit, Power = e.Power
                };
                c.Power *= i;
                a.Add(c);
            }
            var b = new DerivedUnit(a);
            var d = (DerivedMeasure)this.measure;

            b.measure = d.Exponentiation(i);
            return(b);
        }
Beispiel #9
0
 public Unit Divide(DerivedUnit d)
 {
     return(Multiply(d, true));
 }