-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: Add on sphere #2011
Conversation
// 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")); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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:
And for a molecule with a large tail:
TODO