From 2795055b4d0dce92db1e49051d5f24fc43f13095 Mon Sep 17 00:00:00 2001 From: DanielHader Date: Mon, 21 Oct 2024 15:21:45 -0500 Subject: [PATCH 1/2] fixed issue 309 by rotating helix position by group's orientation before adding to helix group's offset --- scadnano/scadnano.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scadnano/scadnano.py b/scadnano/scadnano.py index 397d080..8625516 100644 --- a/scadnano/scadnano.py +++ b/scadnano/scadnano.py @@ -9020,25 +9020,33 @@ def _oxdna_get_helix_vectors(design: Design, helix: Helix) -> Tuple[_OxdnaVector roll_axis = roll_axis.rotate(design.pitch_of_helix(helix), pitch_axis) # then the roll rotation - yaw_axis = yaw_axis.rotate(-design.roll_of_helix(helix), roll_axis) + # note only the group's roll is used here helix rolls are accounted for below + yaw_axis = yaw_axis.rotate(-group.roll, roll_axis) + pitch_axis = pitch_axis.rotate(-group.roll, roll_axis) # by chosen convension, forward is the same as the roll axis # and normal is the negated yaw axis forward = roll_axis normal = -yaw_axis + normal = normal.rotate(-helix.roll, roll_axis) # account for helix roll separately - position = origin + # get the position of the helix within the group + position_in_helix_group = origin if grid == Grid.none: if helix.position is not None: - position = helix.position + position_in_helix_group = helix.position else: if helix.grid_position is None: raise AssertionError('helix.grid_position should be assigned if grid is not Grid.none') - position = grid_position_to_position(helix.grid_position, grid, geometry) + position_in_helix_group = grid_position_to_position(helix.grid_position, grid, geometry) - position = position + group.position + # helix's position in it's group rotated so that it exists in the global rotation + position_in_helix_group_rotated = (pitch_axis * position_in_helix_group.x) + (yaw_axis * position_in_helix_group.y) + (roll_axis * position_in_helix_group.z) - origin_ = _OxdnaVector(position.x, position.y, position.z) * NM_TO_OX_UNITS + # offset of helix group origin with respect to global coordinates + helix_group_offset = _OxdnaVector(group.position.x, group.position.y, group.position.z) + + origin_ = (position_in_helix_group_rotated + helix_group_offset) * NM_TO_OX_UNITS return origin_, forward, normal From cf75e42f05590b7e139cfb52609ec7498d31b900 Mon Sep 17 00:00:00 2001 From: David Doty Date: Mon, 21 Oct 2024 13:38:59 -0700 Subject: [PATCH 2/2] Update scadnano.py --- scadnano/scadnano.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scadnano/scadnano.py b/scadnano/scadnano.py index 8625516..5a26865 100644 --- a/scadnano/scadnano.py +++ b/scadnano/scadnano.py @@ -9041,7 +9041,9 @@ def _oxdna_get_helix_vectors(design: Design, helix: Helix) -> Tuple[_OxdnaVector position_in_helix_group = grid_position_to_position(helix.grid_position, grid, geometry) # helix's position in it's group rotated so that it exists in the global rotation - position_in_helix_group_rotated = (pitch_axis * position_in_helix_group.x) + (yaw_axis * position_in_helix_group.y) + (roll_axis * position_in_helix_group.z) + position_in_helix_group_rotated = ((pitch_axis * position_in_helix_group.x) + + (yaw_axis * position_in_helix_group.y) + + (roll_axis * position_in_helix_group.z)) # offset of helix group origin with respect to global coordinates helix_group_offset = _OxdnaVector(group.position.x, group.position.y, group.position.z)