public override Vector ComputeMagneticMoment(Vector magneticField) { Vector netTorque = Quark1.ComputeMagneticMoment(magneticField); netTorque += Quark2.ComputeMagneticMoment(magneticField); netTorque += Quark3.ComputeMagneticMoment(magneticField); return netTorque; }
public Vector CrossProduct(Vector vector) { Vector newVector = new Vector(); newVector.SetXYZ(Y * vector.Z - Z * vector.Y, Z * vector.X - X * vector.Z, X * vector.Y - Y * vector.X); return newVector; }
public Vector PlanarRotation(double angle) { Vector rotatedVector = new Vector(); double rotMatrix11 = Math.Cos(angle); double rotMatrix12 = -Math.Sin(angle); double rotMatrix21 = Math.Sin(angle); double rotMatrix22 = Math.Cos(angle); rotatedVector.SetXYZ(X * rotMatrix11 + Y * rotMatrix12, X * rotMatrix21 + Y * rotMatrix22, 0); return rotatedVector; }
static void Main(string[] args) { Vector magneticField = new Vector(){X = 0, Y = 1.0, Z = 0}; Proton proton = new Proton(); Vector magneticMoment = proton.ComputeMagneticMoment(magneticField); Console.WriteLine("Proton magnetic moment = {0:E}", magneticMoment.R); Neutron neutron = new Neutron(); magneticMoment = neutron.ComputeMagneticMoment(magneticField); Console.WriteLine("Neutron magnetic moment = {0:E}", magneticMoment.R); SelkeNeutron selkeNeutron = new SelkeNeutron(); magneticMoment = selkeNeutron.ComputeMagneticMoment(magneticField); Console.WriteLine("Selke Neutron magnetic moment = {0:E}", magneticMoment.R); }
public Vector ScalarProduct(double scalar) { Vector newVector = new Vector(); newVector.SetXYZ(X * scalar, Y * scalar, Z * scalar); return newVector; }
public static Vector operator +(Vector aVector, Vector addend) { Vector newVector = new Vector(); newVector.SetXYZ(aVector.X + addend.X, aVector.Y + addend.Y, aVector.Z + addend.Z); return newVector; }
public virtual Vector ComputeMagneticMoment(Vector magneticField) { Vector netTorque = new Vector(); Points.Where(point => point.LoopRadius > Radius / 1000000.0).ToList().ForEach(point => { double velocityMagnitude = AngularVelocity * point.LoopRadius; Vector tangentVector = point.PlanarRotation(VelocityAngleFromRadius); tangentVector = tangentVector.ScalarProduct(velocityMagnitude / tangentVector.R); Vector forceVector = tangentVector.CrossProduct(magneticField).ScalarProduct(point.Charge); netTorque += point.CrossProduct(forceVector); }); return netTorque; }