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

Documentation: layman friendly terminology in cast_ray max_toi #543

Open
andrewbaxter opened this issue Jun 25, 2024 · 4 comments
Open

Documentation: layman friendly terminology in cast_ray max_toi #543

andrewbaxter opened this issue Jun 25, 2024 · 4 comments

Comments

@andrewbaxter
Copy link

andrewbaxter commented Jun 25, 2024

In https://rapier.rs/docs/user_guides/rust/scene_queries it says the limit is [ray.origin, ray.origin + ray.dir * max_toi] suggesting that max_toi is in unit of ray.dir (i.e. toi 1 == ray.origin + ray.dir).

The code docstring says limits the length of the ray to ray.dir.norm() * max_toi (i.e. toi 1 could be before or after ray.origin + ray.dir).

@sebcrozet
Copy link
Member

sebcrozet commented Jun 25, 2024

The ray.dir.norm() refers to the norm of the dir vector (a synonymous for norm is magnitude if that helps).
So ray.dir.norm() * max_toi has the same length as ray.dir * max_toi, making this equivalent to saying that it is limited to ray.origin + ray.dir * max_toi.

@andrewbaxter
Copy link
Author

Ah thanks... I think I'm still a bit confused.

Bevy uses Vec3 which has a normalize() but no norm() method. I assumed norm() meant normalize, but maybe this is wrong - but this is the bevy_rapier documentation so I'd assume bevy conventions. Do you mean norm() returns the length of the vector, like Vec3::length? Vec3::new(10., 0., 0.).normalize() * 3. and Vec3::new(10., 0., 0.) * 3 have two very different lengths.

If that's the case, I still believe it might help if the documentation is updated to use more easily distinguishable terminology. I'm not familiar with that use of norm there are probably others who are the same.

@andrewbaxter
Copy link
Author

And thank you for this library! It's absolutely not something I'd want to write myself.

@sebcrozet
Copy link
Member

Yes, norm is the length of the vector. norm, length, magnitude all mean the same thing here. See wikipedia. The word norm is a slightly more general term, here implied to be the euclidean norm.
The function normalize (both in bevy/glam and rapier/nalgebra) divide the vector by its norm.

@andrewbaxter andrewbaxter changed the title Documentation: inconsistent cast_ray max_toi unit Documentation: layman friendly terminology in cast_ray max_toi Jun 30, 2024
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

No branches or pull requests

2 participants