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

Vector3::Normalize returns Vector3, Vector[24]::Normalize return void #34

Open
osrf-migration opened this issue Dec 1, 2015 · 6 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@osrf-migration
Copy link

Original report (archived issue) by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


We should make these consistent.

@osrf-migration
Copy link
Author

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


Actually, there is a bit of different behavior that can be expected.

For example, we added Transpose and Transposed methods to the matrix classes in pull request #74:

public: void Matrix3::Transpose()
public: Matrix3<T> Matrix3::Transposed() const

The Transpose method acts in place on an existing object, while Transposed is const, so it doesn't affect the base object, but returns a new value.

I think we could do a similar thing for Normalize with the vector classes and perhaps Quaternion as well:

  • Normalize for in-place modification of an object
  • Normalized for creating a new object

I realize this doesn't directly address the title of this issue, which is about return values, but changing that will break API/ABI, so we can wait until the next major release to change the return type if we decide to do so.

@osrf-migration
Copy link
Author

Original comment by Amitoj (Bitbucket: amtj).


I tried the bug, please have a look.
https://bitbucket.org/amtj/ign-math/commits/all

Regards.

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


Here's the complete diff between your branch and this one.

I think it looks like a good start. We should probably also add Vector3::Normalized. And there should be tests for all new functions, see this for example.

@pxalcantara
Copy link
Contributor

pxalcantara commented Oct 17, 2020

I think we could do a similar thing for Normalize with the vector classes and perhaps Quaternion as well:

I think this bug is fixed in the Vector class, Vector3, Vector2 and, Vector4. About the Quaternion to solve this issue, we should add Normalized to the class?

@chapulina
Copy link
Contributor

I think this is still inconsistent:

https://github.com/ignitionrobotics/ign-math/blob/b5306cc9ea8e7ac2075547b227eb5e6c738efb3e/include/ignition/math/Vector3.hh#L133

https://github.com/ignitionrobotics/ign-math/blob/b5306cc9ea8e7ac2075547b227eb5e6c738efb3e/include/ignition/math/Vector2.hh#L102

https://github.com/ignitionrobotics/ign-math/blob/b5306cc9ea8e7ac2075547b227eb5e6c738efb3e/include/ignition/math/Vector4.hh#L149

I agree with the solution proposed by @scpeters above, the problem is that it will be too disruptive. We can't tick-tock deprecate Vector3::Normalize(), we would have to change the return type from Vector3 to void on ign-math7. I think we need to balance the API improvement with the impact on users. Maybe since a lot will change in ign-math7 due to #101, maybe it's a good time to also make this change? What do you think, @scpeters ?

About the Quaternion to solve this issue, we should add Normalized to the class?

Nice catch, it already has void Normalize, so we could add Quaternion<T> Normalized.

https://github.com/ignitionrobotics/ign-math/blob/b5306cc9ea8e7ac2075547b227eb5e6c738efb3e/include/ignition/math/Quaternion.hh#L280-L281

@pxalcantara
Copy link
Contributor

Nice catch, it already has void Normalize, so we could add Quaternion Normalized.

So, I'm planning to work on the implementation of the Quaternion<T> Normalized method.

@azeey azeey added good first issue Good for newcomers help wanted Extra attention is needed labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants