diff --git a/arcade/math.py b/arcade/math.py index a14b85c33c..2198e5c815 100644 --- a/arcade/math.py +++ b/arcade/math.py @@ -235,22 +235,19 @@ def rand_in_circle(center: Point2, radius: float) -> Point2: # random radius r = radius * math.sqrt(random.random()) # calculating coordinates - return (r * math.cos(angle) + center[0], r * math.sin(angle) + center[1]) + return r * math.cos(angle) + center[0], r * math.sin(angle) + center[1] def rand_on_circle(center: Point2, radius: float) -> Point2: """ Generate a point on a circle. - .. note: by passing a random value in for float, - you can achieve what rand_in_circle() does - Args: center (Point2): The center of the circle radius (float): The radius of the circle """ angle = 2 * math.pi * random.random() - return (radius * math.cos(angle) + center[0], radius * math.sin(angle) + center[1]) + return radius * math.cos(angle) + center[0], radius * math.sin(angle) + center[1] def rand_on_line(pos1: Point2, pos2: Point2) -> Point: @@ -284,9 +281,7 @@ def rand_angle_spread_deg(angle: float, half_angle_spread: float) -> float: return angle + s -def rand_vec_spread_deg( - angle: float, half_angle_spread: float, length: float -) -> tuple[float, float]: +def rand_vec_spread_deg(angle: float, half_angle_spread: float, length: float) -> Point2: """ Returns a random vector, within a spread of the given angle. @@ -304,12 +299,12 @@ def rand_vec_magnitude( angle: float, lo_magnitude: float, hi_magnitude: float, -) -> tuple[float, float]: +) -> Point2: """ - Returns a random vector, within a spread of the given angle. + Return a vector of randomized magnitude pointing in the given direction. Args: - angle (float): The angle to spread from + angle (float): The vector angle in radians lo_magnitude (float): The lower magnitude hi_magnitude (float): The higher magnitude """