stk
stk copied to clipboard
Enhancement: Vertex placement of nonlinear vertices
For vertices with > 3 placer atoms, the alignment based on the 'aligning vertex' can be limited (i.e. favouring one edge alignment over all others in nonsymmetric cases would give bad bonding in the other cases.
I suggest we use an algorithm to minimize the angle between all fg_bonder_centroid-self._position
and edge_position-edge_centroid
vectors, rather than just the vector of the aligner edge in these cases. I.e. currently we minimize this angle for one edge and do not check the others, but I suggest trying to find the optimal rotation to minimize all edge angles.
Thoughts?
This code below is the final step of nonlinear vertex placement, which I would suggest modifying.
building_block.with_rotation_to_minimize_angle(
start=fg_bonder_centroid - self._position,
target=edge_position - edge_centroid,
axis=edge_normal,
origin=self._position,
).get_position_matrix()
What if BuildingBlock had a with_rotation_to_minimize_angles
method, that took multiple vectors in the start and target arguments? I.e. (in this case, starter1 would aim to align with target1):
building_block.with_rotation_to_minimize_angles(
start=[starter1, starter2, starter3, starter4],
target=[target1, target2, target3, target4],
axis=edge_normal,
origin=self._position,
).get_position_matrix()
I had a go at this, and was able to get improved orientations for highly anisotropic building blocks in some cases, but could not figure out a robust way to optimise the rotation angle.
In my implementation, you get N angles (one for each FG) that that FG needs to be rotated to be aligned with its specific edge. Currently, the first angle is used (associated with aligner_edge and fg0). However, I want to choose an angle such that all four required rotations are satisfied to the best of their ability.