MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / polar_force

Function polar_force

physics/in_static_equilibrium.py:11–31  ·  view source on GitHub ↗

Resolves force along rectangular components. (force, angle) => (force_x, force_y) >>> import math >>> force = polar_force(10, 45) >>> math.isclose(force[0], 7.071067811865477) True >>> math.isclose(force[1], 7.0710678118654755) True >>> force = polar_force(10, 3.

(
    magnitude: float, angle: float, radian_mode: bool = False
)

Source from the content-addressed store, hash-verified

9
10
11def polar_force(
12 magnitude: float, angle: float, radian_mode: bool = False
13) -> list[float]:
14 """
15 Resolves force along rectangular components.
16 (force, angle) => (force_x, force_y)
17 >>> import math
18 >>> force = polar_force(10, 45)
19 >>> math.isclose(force[0], 7.071067811865477)
20 True
21 >>> math.isclose(force[1], 7.0710678118654755)
22 True
23 >>> force = polar_force(10, 3.14, radian_mode=True)
24 >>> math.isclose(force[0], -9.999987317275396)
25 True
26 >>> math.isclose(force[1], 0.01592652916486828)
27 True
28 """
29 if radian_mode:
30 return [magnitude * cos(angle), magnitude * sin(angle)]
31 return [magnitude * cos(radians(angle)), magnitude * sin(radians(angle))]
32
33
34def in_static_equilibrium(

Callers 1

Calls 2

sinFunction · 0.85
radiansFunction · 0.85

Tested by

no test coverage detected