ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
26.21k stars 1.8k forks source link

Parametric Function not intersecting with Dot3D #3710

Closed internot169 closed 6 months ago

internot169 commented 6 months ago

Description of bug / unexpected behavior

We have a parametric function which we know intersects with two points. However, when rendering the two points and the function, the function does not intersect with the points.

Expected behavior

We expect the function to intersect with the points. This isn't a math issue: I have tried the function and points in GeoGebra and it works.

How to reproduce the issue

Code for reproducing the problem ```py class Main(ThreeDScene): def construct(self): axes = ThreeDAxes() curve = ParametricFunction( lambda u: np.array([ 1 + u, 3 * u, 4 - (5 * u) ]), color=RED, t_range = np.array([0, 1, 0.001]) ).set_shade_in_3d(True) self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES) dot_1 = Dot3D(point=axes.coords_to_point(1, 0, 4), radius=0.1, color=RED) dot_2 = Dot3D(point=axes.coords_to_point(2, 3, -1), radius=0.1, color=BLUE) dot_3 = Dot3D(point=[0, 1, -2], radius=0.1, color=ORANGE) self.add(dot_1, dot_2, dot_3) self.play(Write(axes)) self.play(Create(curve)) self.wait() ```

Additional media files

Images/GIFs ![image](https://github.com/ManimCommunity/manim/assets/97420031/c3f697d9-5b13-4745-ac0d-93ce015349d7)

Logs

Terminal output Manim Community v0.18.0.post0 (process:4020): GLib-GIO-WARNING **: 13:58:45.173: Unexpectedly, UWP app `Microsoft.ScreenSketch_11.2401.37.0_x64__8wekyb3d8bbwe' (AUMId `Microsoft.ScreenSketch_8wekyb3d8bbwe!App') supports 29 extensions but has no verbs (process:4020): GLib-GIO-WARNING **: 13:58:45.213: Unexpectedly, UWP app `Clipchamp.Clipchamp_3.0.10220.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 41 extensions but has no verbs (process:4020): GLib-GIO-WARNING **: 13:58:45.344: Unexpectedly, UWP app `Microsoft.OutlookForWindows_1.2024.403.300_x64__8wekyb3d8bbwe' (AUMId `Microsoft.OutlookForWindows_8wekyb3d8bbwe!Microsoft.OutlookforWindows') supports 4 extensions but has no verbs [04/20/24 13:59:13] INFO Animation 0 : Partial movie file written in 'C:\Users\ajosan25\GithubOpenSrc\advcalc-manim-viz\media\videos\scene\480p15\partial_movie_files\Main\1121228674_1134503466_2063294150.mp4' scene_file_writer.py:527 [04/20/24 13:59:15] INFO Animation 1 : Partial movie file written in 'C:\Users\ajosan25\GithubOpenSrc\advcalc-manim-viz\media\videos\scene\480p15\partial_movie_files\Main\3953065503_92936225_2236974263.mp4' scene_file_writer.py:527 [04/20/24 13:59:17] INFO Animation 2 : Partial movie file written in 'C:\Users\ajosan25\GithubOpenSrc\advcalc-manim-viz\media\videos\scene\480p15\partial_movie_files\Main\3953065503_3467822883_2773469541.mp4' scene_file_writer.py:527 INFO Combining to Movie file. scene_file_writer.py:617 INFO scene_file_writer.py:735 File ready at 'C:\Users\ajosan25\GithubOpenSrc\advcalc-manim-viz\media\videos\scene\480p15\Main.mp4' INFO Rendered Main scene.py:241 Played 3 animations [04/20/24 13:59:19] INFO Previewed File at: 'C:\Users\ajosan25\GithubOpenSrc\advcalc-manim-viz\media\videos\scene\480p15\Main.mp4' ``` PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR ```

System specifications

System Details - OS 11: - RAM: 16GB - Python version: Python 3.10.4 - Installed modules (provide output from `pip list`): ``` Package Version Editable project location ---------------------------- --------------------- --------------------------------------------- absl-py 1.0.0 accelerate 0.23.0 aiohttp 3.8.5 aiosignal 1.3.1 annotated-types 0.5.0 anyio 3.7.1 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 arrow 1.3.0 astroid 2.9.3 asttokens 2.4.0 astunparse 1.6.3 async-generator 1.10 async-lru 2.0.4 async-timeout 4.0.2 atomicwrites 1.4.0 attrs 23.2.0 autopep8 1.6.0 Babel 2.14.0 backcall 0.2.0 beautifulsoup4 4.11.1 bitsandbytes 0.41.1 black 23.7.1.dev33+gd9c249c blamepipeline 0.1.0 c:\users\ajosan25\githubopensrc\blamepipeline bleach 6.1.0 blinker 1.6.2 cachetools 5.0.0 certifi 2024.2.2 cffi 1.15.1 charset-normalizer 3.3.2 click 8.1.7 click-default-group 1.2.4 click-plugins 1.1.1 cligj 0.7.2 cloup 2.1.2 cmake 3.26.0 colorama 0.4.6 comm 0.2.1 cryptography 40.0.1 cssselect 1.1.0 cycler 0.11.0 dataclasses-json 0.6.1 datasets 2.16.1 debugpy 1.8.0 decorator 5.1.1 defusedxml 0.7.1 Deprecated 1.2.13 descartes 1.1.0 dill 0.3.7 diskcache 5.6.3 distro 1.9.0 dlib 19.24.1 dnspython 2.4.2 einops 0.7.0 exceptiongroup 1.1.0 executing 2.0.0 fairscale 0.4.13 fastjsonschema 2.19.1 feedfinder2 0.0.4 feedparser 6.0.10 filelock 3.6.0 Fiona 1.9.4.post1 fire 0.5.0 Flask 2.3.2 Flask-Cors 4.0.0 Flask-Login 0.6.2 Flask-SQLAlchemy 3.0.3 flatbuffers 2.0 fonttools 4.29.0 fqdn 1.5.1 frozenlist 1.3.3 fsspec 2023.9.2 gast 0.5.3 geopandas 0.13.2 github 1.2.7 glcontext 2.5.0 google-api-core 2.7.1 google-auth 2.6.0 google-auth-oauthlib 0.4.6 google-cloud 0.34.0 google-cloud-core 2.2.3 google-cloud-datastore 1.15.5 google-cloud-ndb 1.11.1 google-cloud-secret-manager 2.9.2 google-cloud-storage 2.2.1 google-crc32c 1.3.0 google-pasta 0.2.0 google-resumable-media 2.3.2 googleapis-common-protos 1.55.0 greenlet 2.0.2 grpc-google-iam-v1 0.12.3 grpcio 1.60.0 grpcio-status 1.44.0 grpcio-tools 1.60.0 h11 0.14.0 h2 4.1.0 h5py 3.6.0 hpack 4.0.0 html5lib 1.1 httpcore 1.0.2 httpx 0.26.0 huggingface-hub 0.20.3 hyperframe 6.0.1 idna 3.7 iniconfig 1.1.1 ipykernel 6.29.0 ipython 8.16.1 isoduration 20.11.0 isort 5.10.1 isosurfaces 0.1.0 itsdangerous 2.1.2 jedi 0.19.1 jieba3k 0.35.1 Jinja2 3.1.2 joblib 1.1.0 json5 0.9.14 jsonpatch 1.33 jsonpointer 2.4 jsonschema 4.21.0 jsonschema-specifications 2023.12.1 jupyter_client 8.6.0 jupyter_core 5.7.1 jupyter-events 0.9.0 jupyter-lsp 2.2.1 jupyter_server 2.12.5 jupyter_server_terminals 0.5.1 jupyterlab 4.0.10 jupyterlab_pygments 0.3.0 jupyterlab_server 2.25.2 keras 2.8.0 Keras-Preprocessing 1.1.2 kiwisolver 1.3.2 langchain 0.1.16 langchain-community 0.0.32 langchain-core 0.1.42 langchain-experimental 0.0.57 langchain-openai 0.0.3 langchain-text-splitters 0.0.1 langsmith 0.1.47 lazy-object-proxy 1.7.1 libclang 13.0.0 llama_cpp_python 0.2.11 llama-index 0.8.38 lxml 4.9.0 mailtrap 2.0.1 manim 0.18.0.post0 ManimPango 0.5.0 mapbox-earcut 1.0.1 Markdown 3.3.6 markdown-it-py 3.0.0 MarkupSafe 2.1.1 marshmallow 3.20.1 matplotlib 3.5.1 matplotlib-inline 0.1.6 mccabe 0.6.1 mdurl 0.1.2 mistune 3.0.2 moderngl 5.10.0 moderngl-window 2.4.4 mpmath 1.2.1 msal 1.26.0 multidict 6.0.4 multipledispatch 1.0.0 multiprocess 0.70.15 mypy-extensions 0.4.3 nbclient 0.9.0 nbconvert 7.14.2 nbformat 5.9.2 nest-asyncio 1.5.8 networkx 3.2.1 newspaper3k 0.2.8 nltk 3.7 notebook 7.0.6 notebook_shim 0.2.3 numexpr 2.8.7 numpy 1.26.4 oauthlib 3.2.0 openai 1.9.0 opencv-python 4.7.0.72 opt-einsum 3.3.0 orjson 3.10.0 outcome 1.2.0 overrides 7.4.0 packaging 23.2 pandas 1.4.0 pandocfilters 1.5.0 parso 0.8.3 pathspec 0.9.0 patsy 0.5.3 pickleshare 0.7.5 Pillow 9.5.0 pip 24.0 platformdirs 2.5.1 plotly 5.16.1 plotly-express 0.4.1 plotly-geo 1.0.0 pluggy 1.0.0 portalocker 2.8.2 prometheus-client 0.19.0 prompt-toolkit 3.0.39 proto-plus 1.20.3 protobuf 3.20.3 psutil 5.9.5 pure-eval 0.2.2 py 1.11.0 pyarrow 15.0.0 pyarrow-hotfix 0.6 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycairo 1.26.0 pycodestyle 2.8.0 pycparser 2.21 pydantic 2.4.2 pydantic_core 2.10.1 pydub 0.25.1 pygame 2.3.0 PyGithub 1.58.1 pyglet 2.1.dev2 Pygments 2.17.2 PyJWT 2.6.0 pylint 2.12.2 pymemcache 3.5.2 pymongo 4.5.0 PyNaCl 1.5.0 pyparsing 3.0.7 pypdf 3.16.2 pyproj 3.6.0 pyrr 0.10.3 pysbd 0.3.4 pyshp 2.3.1 PySocks 1.7.1 pytest 7.1.0 python-dateutil 2.8.2 python-dotenv 0.21.0 python-json-logger 2.0.7 pytz 2021.3 pywin32 306 pywinpty 2.0.12 PyYAML 6.0 pyzmq 25.1.2 qdrant-client 1.7.0 ragas 0.0.22 redis 4.3.4 referencing 0.32.1 regex 2022.1.18 requests 2.31.0 requests-file 1.5.1 requests-oauthlib 1.3.1 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rich 13.7.1 rpds-py 0.17.1 rsa 4.8 sacremoses 0.0.47 scikit-learn 1.0.2 scipy 1.13.0 screeninfo 0.8.1 seaborn 0.11.2 selenium 4.7.2 Send2Trash 1.8.2 sentence-transformers 2.2.2 sentencepiece 0.1.99 setuptools 58.1.0 sgmllib3k 1.0.0 shapely 2.0.1 six 1.16.0 skia-pathops 0.7.4 sniffio 1.3.0 snscrape 0.7.0.20230622 sortedcontainers 2.4.0 soupsieve 2.3.2.post1 SQLAlchemy 2.0.21 srt 3.5.3 stack-data 0.6.3 statsmodels 0.14.0 svgelements 1.9.6 sympy 1.11.1 tenacity 8.2.3 tensorboard 2.8.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow 2.8.0 tensorflow-io-gcs-filesystem 0.23.1 termcolor 1.1.0 terminado 0.18.0 tf-estimator-nightly 2.8.0.dev2021122109 threadpoolctl 3.0.0 tiktoken 0.5.2 tinycss2 1.2.1 tinysegmenter 0.3 tldextract 3.3.0 tokenizers 0.11.6 toml 0.10.2 tomli 2.0.1 torch 2.0.0 torchaudio 2.0.1+cu117 torchdata 0.6.1 torchtext 0.15.2 torchvision 0.15.1+cu117 tornado 6.4 tqdm 4.66.2 traitlets 5.11.2 transformers 4.17.0 tree-sitter 0.20.2 tree-sitter-languages 1.7.0 trio 0.22.0 trio-websocket 0.9.2 types-python-dateutil 2.8.19.20240106 typing_extensions 4.11.0 typing-inspect 0.9.0 uri-template 1.3.0 urllib3 2.2.1 vaderSentiment 3.3.2 watchdog 3.0.0 wcwidth 0.2.8 webcolors 1.13 webdriver-manager 3.8.5 webencodings 0.5.1 websocket-client 1.7.0 Werkzeug 2.3.4 wheel 0.43.0 wrapt 1.13.3 wsproto 1.2.0 xxhash 3.4.1 yarl 1.8.2 ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages:
FFMPEG Output of `ffmpeg -version`: ``` ffmpeg version 7.0-essentials_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 ```

Additional comments

internot169 commented 6 months ago

Sorry, Installed LaTeX packages are MiKTeX

uwezi commented 6 months ago

your ParametricFunction() object uses scene coordinates, not the ones defined by your axes object, while you place your dots using the local coordinate system of your axes object.

before: image

after: image

        curve = axes.plot_parametric_curve(
            lambda u: np.array([
                1 + u,
                3 * u,
                4 - (5 * u)
            ]), color=RED, t_range = np.array([0, 1, 0.001])
        ).set_shade_in_3d(True)
internot169 commented 6 months ago

Thanks! It works now.