Exemplo n.º 1
0
        public new static Force InteractionForce(Particle A, Particle B)
        {
            Displacement AtoB             = B.position - A.position;
            Scalar       distance         = AtoB.Magnitude();
            Scalar       magnitudeOfForce = G * (A.mass * B.mass) / (distance * distance);

            return(new Force(magnitudeOfForce * AtoB.Direction()));
        }
Exemplo n.º 2
0
        /// <summary>
        /// The force this spring would apply if stretched/compressed to the given Displacement
        /// </summary>
        /// <param name="xToY"></param>
        /// <returns>The force this spring would apply if stretched/compressed to the given Displacement</returns>
        public Force InteractionForce(Displacement xToY)
        {
            // <summary> returns force on x due to y </summary>
            if (xToY.units != DerivedUnits.Length)
            {
                throw new UnitMismatchException();
            }
            Scalar magnitude = SpringRate * (xToY.Magnitude() - RestLength);

            return(new Force(magnitude * xToY.Direction()));
        }