Source code for pooltool.physics.resolve.ball_ball
"""Models for ball-ball collisions."""fromtypingimportDict,Optional,Typefrompooltool.physics.resolve.ball_ball.coreimportBallBallCollisionStrategyfrompooltool.physics.resolve.ball_ball.frictional_mathavanimportFrictionalMathavanfrompooltool.physics.resolve.ball_ball.frictionless_elasticimportFrictionlessElasticfrompooltool.physics.resolve.typesimportModelArgsfrompooltool.utils.strenumimportStrEnum,auto
[docs]classBallBallModel(StrEnum):"""An Enum for different ball-ball collision models Attributes: FRICTIONLESS_ELASTIC: Frictionless, instantaneous, elastic, equal mass collision (:class:`FrictionlessElastic`). """FRICTIONLESS_ELASTIC=auto()FRICTIONAL_MATHAVAN=auto()
[docs]defget_ball_ball_model(model:Optional[BallBallModel]=None,params:ModelArgs={})->BallBallCollisionStrategy:"""Returns a ball-ball collision model Args: model: An Enum specifying the desired model. If not passed, :class:`FrictionalMathavan` is passed with empty params. params: A mapping of parameters accepted by the model. Returns: An instantiated model that satisfies the :class:`BallBallCollisionStrategy` protocol. """ifmodelisNone:returnFrictionlessElastic()return_ball_ball_models[model](**params)