Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vector field support #42

Merged
merged 8 commits into from
May 24, 2024
Merged

Add vector field support #42

merged 8 commits into from
May 24, 2024

Conversation

phohenberger
Copy link
Contributor

This adds vector field support by:

  • Adding a new arrow mesh with the scale parameter
  • VectorField class that is analogue to Particle but contains different parameter direction for the direction of the vectors. The current design is such that each position is assigned the corresponding direction vector in the list of given positions and vectors.
  • optional vector_field parameter for the visualizer that works the same as particles, but is declared seperately and takes in a VectorField instance

Note that the initial rendering is quite slow for large numbers of vectors. This could be optimized somehow.

Example Syntax:

v_mat = vis.Material(colour=np.array([0, 0, 255]) / 255)
v_mesh = vis.Arrow(scale = 10, material = v_mat)
v_field = vis.VectorField(name="flow", mesh=v_mesh, position=pos, direction=dir)

visualizer = vis.Visualizer(particles=[...], vector_field=[v_field], frame_rate=30)

The variables pos and dir are of the shape (n_steps, n_vectors, n_dims = 3)

Copy link
Member

@SamTov SamTov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. There were some small things like type hints, ensuring all modules have their full import and new lines at the end of the page. But as they were all very small I just did it myself.

Thanks for the awesome PR! @christophlohrmann This will solve some of your visualisation requests.

@SamTov SamTov merged commit 4a043d5 into zincware:main May 24, 2024
1 check passed
@phohenberger phohenberger deleted the vector_field branch June 12, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants