using System; using Science.Mathematics; using L=Science.Physics.GeneralPhysics; namespace Serway.Chapter09 { /// /// Example14: The Center of Mass of a Rod /// (A) Show that the center of mass of a rod of mass M and /// length L lies midway between its ends, assuming the rod /// gas a uniform mass per unit length. /// x_{cm} = L/2 /// (B) Suppose a rod is nonuniform such that its mass per /// unit length varies linearly with x according to the /// expression \lambda = \alpha x, where \alpha is a constant. /// Find the x coordinate of the center of mass as /// a fraction of L. /// x_{cm} = 2/3*L /// public class Example14 { public Example14() { } private string result; public string Result { get{return result;} } public void Compute() { L.Volume volume = new L.Volume(); volume.XTo = 0.0; volume.XFrom = 1.0; volume.YTo = 0.0; volume.YFrom =0.001; volume.ZTo = 0.0; volume.ZFrom = 0.001; L.Scalar.FunctionOfPosition func = new L.Scalar.FunctionOfPosition(f); L.Density density = new L.Density(); density.ScalarFunctionOfPosition = func; L.CenterOfMass xcm = new L.CenterOfMass(density, volume); result+=xcm.ToString(); } private L.Scalar f(L.Position x) { L.Scalar s = new L.Scalar(); double alpha = 10.0; s.Magnitude = alpha*x.X; return s; } } } //0.666663319345636 +/- -2.20297178913849E-05 i //+0.000499965219523787 +/- -1.94073884680785E-08 j //+0.000500004179197523 +/- -1.93767803491175E-08 k (m)