ManimCommunity / ManimCommunity/manim

geometry: unify generate_points and init_points in Arc

Open
#4,803 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Source

`manim/mobject/geometry/arc.py`, line 345 (as of HEAD ):

```
def generate_points(self) -> None:
self._set_pre_positioned_points()
self.scale(self.radius, about_point=ORIGIN)
self.shift(self.arc_center)

# Points are set a bit differently when rendering via OpenGL.
# TODO: refactor Arc so that only one strategy for setting points
# has to be used.
def init_points(self) -> None:
self.set_points(
Arc._create_quadratic_bezier_points(
angle=self.angle,
start_angle=self.start_angle,
n_components=self.num_components,
),
)
self.scale(self.radius, about_point=ORIGIN)
self.shift(self.arc_center)
```

## Problem

The `Arc` class exposes two methods that compute and position points in slightly different ways: `generate_points()` and `init_points()`. The duplication exists because the Cairo and OpenGL renderers historically needed different point-setting strategies. The trailing operations (`scale` and `shift`) are identical between the two.

Maintaining both methods doubles the surface for regressions — any change to how arc points are positioned has to be made in both places, and it is easy to update one and forget the other.

## Suggested approaches

- Extract the common scale/shift tail into a helper, and have both methods delegate the actual point computation to a single strategy selected by renderer type.
- Investigate whether the Cairo/OpenGL distinction is still necessary, or whether the codebase has converged enough that a single point-setting routine suffices.
- Audit related geometry classes (subclasses of `Arc`, and other shapes in `manim/mobject/geometry/`) for the same duplication pattern.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in manim/mobject/geometry/arc.py around line 345 and compare Arc.generate_points() with init_points(). Investigate whether the Cairo/OpenGL point-setting distinction is still required, then inspect Arc subclasses and related shapes in manim/mobject/geometry/ for the same pattern. Done means reducing duplicated positioning logic without changing Arc behavior and accounting for any necessary renderer-specific strategy.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.