brownian module#
- class Circle(coords, diameter, velocity=None, theta=3, stop_and_rotate=False)[source]#
Class representing a point/circle with Brownian motion.
- Parameters:
coords (numpy.ndarray) – The initial coordinates of the circle.
diameter (int) – Diameter of the circle.
velocity (numpy.ndarray, optional) – Initial velocity of the circle. If None, a random velocity is assigned.
theta (int, optional) – Angular velocity for rotation. (Defaul:
3
)stop_and_rotate (bool, optional) – This is because of the the ambigous requirement of the challenge (Default:
False
)
- checkCollision(coords, boundary)[source]#
Check if the circle collides with the specified boundary.
- Parameters:
coords (numpy.ndarray) – Current coordinates of the circle.
boundary (numpy.ndarray) – Boundary dimensions.
- Returns:
True if collision occurs, False otherwise.
- Return type:
(bool)
- move(dt, maxX, maxY)[source]#
Move the circle based on its state.
- Parameters:
dt – Time step for movement.
maxX – Maximum x-coordinate for the boundary.
maxY – Maximum y-coordinate for the boundary.
- get_random_velocity()[source]#
Generate a random velocity vector.
Samples velocity magnitude from a normal distribution \(\mathcal{N}(\mu, \sigma^2)\), where \(\mu = 500\) and \(\sigma = 200\), and clips it as
\[\begin{split}\lVert V \rVert = \begin{cases} V, & \text{if} \ V_{\text{min}} \leq V \leq V_{\text{max}} \\ V_{\text{min}}, & \text{if} \ V \leq V_{\text{min}} \\ V_{\text{max}}, & \text{if} \ V \geq V_{\text{max}} \end{cases}\end{split}\]where \(V_{\text{min}} = 100\) and \(V_{\text{max}} = 900\).
Then randomly assigns direction to the velocity.
- Returns:
Random velocity vector \(V\).
- Return type:
- class MainWindow(args, timDelta=0.001)[source]#
MainWindow for Brownian motion simulation using tkinter.
- set_random_velocity()[source]#
Set a random velocity for the circle on button click. Internally calls
Circle.get_random_velocity()