MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

physics/n_body_simulation.py:29–49  ·  view source on GitHub ↗

The parameters "size" & "color" are not relevant for the simulation itself, they are only used for plotting.

(
        self,
        position_x: float,
        position_y: float,
        velocity_x: float,
        velocity_y: float,
        mass: float = 1.0,
        size: float = 1.0,
        color: str = "blue",
    )

Source from the content-addressed store, hash-verified

27
28class Body:
29 def __init__(
30 self,
31 position_x: float,
32 position_y: float,
33 velocity_x: float,
34 velocity_y: float,
35 mass: float = 1.0,
36 size: float = 1.0,
37 color: str = "blue",
38 ) -> None:
39 """
40 The parameters "size" & "color" are not relevant for the simulation itself,
41 they are only used for plotting.
42 """
43 self.position_x = position_x
44 self.position_y = position_y
45 self.velocity_x = velocity_x
46 self.velocity_y = velocity_y
47 self.mass = mass
48 self.size = size
49 self.color = color
50
51 @property
52 def position(self) -> tuple[float, float]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected