Fix ORTEP arc boundary: use ellipsoid silhouette normal condition instead of Pz=0#17
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/dkratzert/Fastmolwidget/sessions/77cb040b-7ac1-41b1-86dd-44b96983ccce Co-authored-by: dkratzert <3948149+dkratzert@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
dkratzert
May 9, 2026 11:28
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
In
_draw_principal_arcsthe boundary between the solid (front) and absent (back) halves of each principal great-circle arc was determined by where the z-coordinate of the 3D point on the arc is zero (Pz = 0).The correct ORTEP criterion is where the outward normal of the ellipsoid is perpendicular to the viewing direction, i.e.
(U⁻¹P)_z = 0.For a point
P(t) = rᵢ·vᵢ·cos(t) + rⱼ·vⱼ·sin(t)lying on the ellipsoid surface:Setting this to zero gives
phi_n = atan2(vⱼ[2]·rᵢ, vᵢ[2]·rⱼ).The old code computed
phi_z = atan2(rⱼ·vⱼ[2], rᵢ·vᵢ[2])— the roles ofrᵢandrⱼare swapped compared to the correct formula.Effect
Pz = 0)The two conditions are identical for isotropic ellipsoids (
rᵢ = rⱼ), which is why only some ellipsoids showed the wrong curves.Fix
A 2-line change in
_draw_principal_arcs:Tests
192 tests pass (1 pre-existing failure due to missing
PILdependency, unrelated to this change).