13
13
14
14
15
15
def _solve (
16
- ball : Ball , cushion : LinearCushionSegment
16
+ ball : Ball , cushion : LinearCushionSegment , restitution : bool = True
17
17
) -> Tuple [Ball , LinearCushionSegment ]:
18
- """Given ball and cushion, unrealistically reflect the ball's momentum"""
18
+ """Given ball and cushion, unrealistically reflect the ball's momentum
19
+
20
+ Args:
21
+ restitution:
22
+ By default, the ball's momentum is reflected without loss. Set this to true
23
+ if the ball's restitution coefficient should dampen the outgoing velocity.
24
+ """
19
25
rvw = ball .state .rvw
20
26
21
27
# Two things about the normal:
@@ -40,9 +46,9 @@ def _solve(
40
46
rvw_R = ptmath .coordinate_rotation (rvw .T , - psi ).T
41
47
42
48
# Reverse velocity component lying in normal direction
43
- rvw_R [1 , 0 ] *= - 1
49
+ rvw_R [1 , 0 ] *= - 1 * ( 1 if not restitution else ball . params . e_c )
44
50
45
- # Rotate frame of refernce back to the table frame
51
+ # Rotate frame of reference back to the table frame
46
52
rvw = ptmath .coordinate_rotation (rvw_R .T , psi ).T
47
53
48
54
# Set the ball's rvw
@@ -56,7 +62,9 @@ def _solve(
56
62
57
63
@attrs .define
58
64
class UnrealisticLinear (CoreBallLCushionCollision ):
65
+ restitution : bool = True
66
+
59
67
def solve (
60
68
self , ball : Ball , cushion : LinearCushionSegment
61
69
) -> Tuple [Ball , LinearCushionSegment ]:
62
- return _solve (ball , cushion )
70
+ return _solve (ball , cushion , self . restitution )
0 commit comments