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

Functions for calculating angles between vectors. #13008

Merged
merged 1 commit into from Nov 30, 2021

Conversation

marcfehling
Copy link
Member

For future patches, I need to calculate angles between vectors, but found similar functionality already hidden in the library. I thought it would be a good idea to make them available throughout the library.

I thought the Physics namespace would be good place for these functions. Since they are short I left the implementation in the header and flagged them inline. I would like to know what you think of this approach. We can move these functions to more appropriate places if you have better ideas :-)

Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

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

I like it. Want to add a changelog entry?

include/deal.II/physics/relations.h Outdated Show resolved Hide resolved
include/deal.II/physics/relations.h Outdated Show resolved Hide resolved
include/deal.II/physics/relations.h Outdated Show resolved Hide resolved
Physics::Relations::angle(const Tensor<1, spacedim, Number> &a,
const Tensor<1, spacedim, Number> &b)
{
Assert(a.norm() > 1.e-12 && b.norm() > 1.e-12,
Copy link
Member

Choose a reason for hiding this comment

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

I'm not generally a fan of these sorts of comparisons because the vectors may well have physical units -- and in that case, what is small and what is large is all relative. I wouldn't object to a comparison of the form

Suggested change
Assert(a.norm() > 1.e-12 && b.norm() > 1.e-12,
Assert(a.norm() > 1.e-12*b.norm() && b.norm() > 1.e-12*a.norm(),

Copy link
Member

@kronbichler kronbichler left a comment

Choose a reason for hiding this comment

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

Looks good to me, apart from the comment already given by @bangerth

@marcfehling
Copy link
Member Author

/rebuild

I've addressed all comments. Could you have another look?

@kronbichler kronbichler merged commit 1842c56 into dealii:master Nov 30, 2021
@marcfehling marcfehling deleted the angle-2 branch November 30, 2021 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants