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

feat: Add on sphere #2011

Merged
merged 15 commits into from
Nov 19, 2024
Merged

feat: Add on sphere #2011

merged 15 commits into from
Nov 19, 2024

Conversation

trisyoungs
Copy link
Member

@trisyoungs trisyoungs commented Nov 14, 2024

This PR implements a new Add-style node which places a number of molecules on the surface of a sphere through a reference site on the Species, with the optional ability to orient one site axis along the surface tangent. Two positioning methods are implemented - fully random and one based on a Fibonacci lattice, with the latter giving eye-pleasing results like this:

image

And for a molecule with a large tail:

image

TODO

  • Node icon
  • Documentation

@trisyoungs trisyoungs marked this pull request as ready for review November 14, 2024 13:43
Comment on lines +130 to +153
// Create orthogonal matrix around supplied single column vector
void Matrix3::createFromVector(const Vec3<double> &v, int columnIndex)
{
setColumn(columnIndex, v);
const auto v2 = v.orthogonal();
switch (columnIndex)
{
case 0:
setColumn(1, v2);
setColumn(2, v * v2);
break;
case 1:
setColumn(0, v2);
setColumn(2, v * v2);
break;
case 2:
setColumn(0, v2);
setColumn(1, v * v2);
break;
default:
throw(std::runtime_error("Invalid column index.\n"));
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll admit that I had to read this three times to get how it worked, but, once, I did, I couldn't think of a clearer way to write it. This is perfectly succinct.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also thought about this for quite a while before settling on the "long-winded" way here. A std::set of {0,1,2} with the supplied columnIndex subsequently removed allowed you to remove the switch completely, but felt a little clunky in practice.

@trisyoungs trisyoungs merged commit 84bd77c into develop Nov 19, 2024
11 checks passed
@trisyoungs trisyoungs deleted the add-on-sphere branch November 19, 2024 14:11
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