Dihedral angle atan2

From XuShuwenn/RedAct · View interactive version

Dihedral angle atan2 is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Compute signed dihedral (torsion) angles from four 3D points and report degrees in [-180, 180] using a robust atan2 formulation.

How to use this skill

Skill file

Robust Dihedral (Torsion) Angle Computation

This skill computes the signed dihedral angle defined by four ordered 3D points using a numerically stable atan2-based formulation. It standardizes sign conventions, handles degeneracy checks, and guides precise output formatting.

When to Use

Use this skill when a task asks to:

Core Workflow

  1. Parse Input
  1. Define Bond Vectors
  1. Plane Normals
  1. atan2 Dihedral Formula (signed and robust)
  1. Rounding and Output

Verification

Implement these checks before finalizing output:

φ_alt = atan2(|b1| · det(b0, b1, b2), v · w) with det(b0,b1,b2) = b1 · (b0 × b2).

Common Pitfalls and Fixes

Success Criteria

Optional Script Usage

You can use scripts/dihedral.py to compute the dihedral from either a file containing four lines of "x y z" or from 12 numeric arguments:

The script prints the angle and, if an output path is provided, writes a formatted line: "Dihedral angle: XX.XX degrees".

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.