A 3D vector field simulation framework for visualizing path attraction toward target position(s) on the XY-plane while avoiding obstacles.This project models a mathematical force field that simulates a surface of attraction cones pulling toward targets and repelling from obstacles. Imagine a curved terrain where a ball always rolls toward the lowest point — the target.
This approach is particularly useful in autonomous control systems where the agent’s position is known and obstacles are predefined. The normalized vector of the negative gradient consistently points away from obstacles and toward the desired target.
You can also explore a more visually polished, though simplified, version created in Desmos:
https://www.desmos.com/3d/gxrvqlc4xg
At the time of working on this project, we were studying divergence, curl, and gradients in my math class. I was fascinated by their practical applications, so I began experimenting with vector fields and surfaces in Desmos. Once I reached the limits of what Desmos could offer, I transitioned to Python to explore these concepts further.
Implementing the math models in Python required me to consider computational efficiency, which ultimately led to significant simplification of the original formulas - this is why the mathematical formulas in the Desmos simulation differ from their analogous implementation in this project.
- Vector field based on distance-scaled conic attraction
- Adjustable coefficient values for calculations in
config.py - Functionality to easily add more obstacles or target positions in
main.py - Fully 3D Plotly visualizations
- Built-in simulation viewer (
display.ipynb)
Note: It is recommended to use Visual Studio Code, as the project has only been tested there.
Clone the repository and install dependencies:
git clone https://github.com/Vlarkus/target-pursue-obstacle-avoidance.git
cd target-pursue-obstacle-avoidance
pip install -r requirements.txt- Launch the Jupyter Notebook via terminal or extension (
display.ipynb):
jupyter notebook target_pursue/display.ipynb- Run
%run main.py
I created this project over several days during spring break. Unfortunately, due to upcoming exams, I won't have time to fully optimize the code or add all the features I initially envisioned. However, here are some potential next steps:
-
Fully implement an interactive Agent class that displays a point and a unit vector based on the simulation.
-
Enable the agent to move dynamically according to the calculated vector field.
-
Add a pathfinding algorithm (e.g. A*) to allow the agent to intelligently navigate around obstacles, especially in scenarios where turning corners is difficult.
Created by Vlarkus, 2025
Feel free to fork, star, or contribute :)

