bitshifter / glam-rs

A simple and fast linear algebra library for games and graphics
Apache License 2.0
1.5k stars 152 forks source link

Add helper function to project one vector to a plane #538

Closed johannesvollmer closed 2 months ago

johannesvollmer commented 2 months ago

A very simple but often used helper. it should be as simple as this:

fn projected_on_plane(vector: Vec3, plane_normal: Vec3) -> Vec3 {
    vector - vector.project_onto(plane_normal)
}
LPGhatguy commented 2 months ago

This is available in glam right now as reject_from and it's very useful!

bitshifter commented 2 months ago

Thanks for pointing that out @LPGhatguy :)

One thing I can do is add a doc alias so if someone docs a doc search for project for example it will bring up this method. I can add a doc alias if you can think of an appropriate alias and think it would be useful @johannesvollmer , if not I'll close this.

johannesvollmer commented 2 months ago

Awesome, thanks for the ideas! ✨ Sounds like maybe I just didn't know the correct name. That being said, it could help other people if the doc string contains the "plane" keyword. :)

I have another wish for a built-in function, should I open another issue for it, or would you suggest a different workflow?

bitshifter commented 2 months ago

Generally I prefer it if new features and suggested in https://github.com/bitshifter/glam-rs/discussions/, it's easy enough to turn a discussion into an issue if it's something I want to add.

Added a doc "plane" doc alias for reject_from.

johannesvollmer commented 2 months ago

Awesome! I know it can be exhausting to maintain auch a popular open source project. Thanks for taking the time and being friendly :)