using System; using GP = Science.Physics.GeneralPhysics; namespace ScienceTest.PhysicsTest.GeneralPhysicsTest { /// /// CenterOfMassTest /// public class CenterOfMassTest { private string result; public string Result { get{return result;} } public CenterOfMassTest() { } public void Compute() { GP.Scalar.FunctionOfPosition func = new GP.Scalar.FunctionOfPosition(Den); GP.Density rho = new GP.Density(); rho.ScalarFunctionOfPosition = func; GP.Volume.Parameterization ff = new GP.Volume.Parameterization(PtoP); GP.Volume v = new GP.Volume(); v.ParameterToPosition = ff; v.Parameter1StartValue = 0.0; v.Parameter1EndValue = 1.0; v.Parameter2StartValue = 0.0; v.Parameter2EndValue = 2.0; v.Parameter3StartValue = 0.0; v.Parameter3EndValue = 3.0; GP.CenterOfMass p = new GP.CenterOfMass(rho,v); result += p.ToString(); } private GP.Scalar Den(GP.Position r) { GP.Scalar s = new GP.Scalar(); s.Magnitude = 1.0+r.X; return s; } private GP.Position PtoP(double x, double y, double z) { GP.Position r = new GP.Position(); r.X = x; r.Y = y; r.Z = z; return r; } } } /* 0.555562033880675 +/- 1.5568337720339E-05 i +1.0000370659535 +/- 2.5399024655362E-05 j +1.50000177582779 +/- 3.81592123862233E-05 k (m) */