/// <summary> /// Implements the + operator. /// </summary> /// <param name="a">a.</param> /// <param name="b">The b.</param> /// <returns>The result of the operator.</returns> /// <exception cref="ArgumentException">Masses must both be in local coordinate systems in order to be added together.</exception> public static Mass operator +(Mass a, Mass b) { if (a == null) { return(b); } if (b == null) { return(a); } if (!a.IsLocalCoordinateSystem || !b.IsLocalCoordinateSystem) { throw new ArgumentException("Masses must both be in local coordinate systems in order to be added together."); } ApiMass massA = a.GetMass(); ApiMass massB = b.GetMass(); ApiMass mass = new ApiMass() { U1 = massA.U1 + massB.U1, U2 = massA.U2 + massB.U2, U3 = massA.U3 + massB.U3, R1 = massA.R1 + massB.R1, R2 = massA.R2 + massB.R2, R3 = massA.R3 + massB.R3 }; return(new Mass(mass)); }
/// <summary> /// Initializes a new instance of the <see cref="Mass"/> class. /// </summary> /// <param name="mass">The mass.</param> /// <param name="isLocalCoordinateSystem">if set to <c>true</c> [is local coordinate system].</param> internal Mass(ApiMass mass, bool isLocalCoordinateSystem = true) { _mass = mass; IsLocalCoordinateSystem = isLocalCoordinateSystem; }