FarseerPhysics.Collision.Shapes.CircleShape.computeSubmergedArea C# (CSharp) Method

computeSubmergedArea() public method

public computeSubmergedArea ( Vector2 &normal, float offset, Transform &xf, Vector2 &sc ) : float
normal Vector2
offset float
xf Transform
sc Vector2
return float
		public override float computeSubmergedArea( ref Vector2 normal, float offset, ref Transform xf, out Vector2 sc )
		{
			sc = Vector2.Zero;

			var p = MathUtils.mul( ref xf, position );
			float l = -( Vector2.Dot( normal, p ) - offset );
			if( l < -radius + Settings.epsilon )
			{
				//Completely dry
				return 0;
			}
			if( l > radius )
			{
				//Completely wet
				sc = p;
				return Settings.pi * _2radius;
			}

			//Magic
			float l2 = l * l;
			float area = _2radius * (float)( ( Math.Asin( l / radius ) + Settings.pi / 2 ) + l * Math.Sqrt( _2radius - l2 ) );
			float com = -2.0f / 3.0f * (float)Math.Pow( _2radius - l2, 1.5f ) / area;

			sc.X = p.X + normal.X * com;
			sc.Y = p.Y + normal.Y * com;

			return area;
		}