ManimCommunity / ManimCommunity/manim

Turning a coordinate or object to a coordinate (i.e. make _pointify publicly available)

Open
#3,239 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## Description of proposed feature

In some libraries I don’t want to consider whether the user gives a coordinate or a mobject as input. For instance, to compute the barycenter between two points or objects (it’s also weird to see that no such native function exists in Manim.

I’d therefore love to have:
- a function to convert a point/object to coordinate, like:
```
def to_point(mob_or_point, direction=None):
if isinstance(mob_or_point, (Mobject, OpenGLMobject)):
mob = mob_or_point
if direction is None:
return mob.get_center()
else:
return mob.get_boundary_point(direction)
return np.array(mob_or_point)
```
- a function to compute the barycenter between two objects, like:
```
def barycenter(obj1, obj2, alpha=1/2): ## Ideally: also work for a set of points, where alpha is a list of size n-1
return (1-alpha)*to_point(obj1) + alpha*to_point(obj2)
```
It could for instance improve the midpoint function (https://docs.manim.community/en/stable/_modules/manim/utils/space_ops.html#midpoint) to work on arbitrary objects with a parameter alpha.

## How can the new feature be used?

In many ways. For instance to define animations where we need to place points depending on other points.

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 by reading the existing midpoint implementation in manim/utils/space_ops.py and locate the internal _pointify behavior referenced by the issue. Determine how coordinate and Mobject inputs, optional directions, and barycenter interpolation should be covered; done means the agreed public API works for the described inputs with corresponding tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.