Skip to content

Commit caa4987

Browse files
seto77claude
andcommitted
Simplify symmetry diagram rendering and centering-aware screw detection
Remove the F-cubic-specific representation policy from SymmetryDiagramElements and let SymmetryElementsTable enumerate cubic 23 / m-3 axes directly. Make ScrewParams lattice-aware via PrimitiveAlongDirectionInDUnits so I-cubic body diagonals report the correct k. Canonicalize centered ops in ExpandWithCentering so axis positions are not duplicated. Unify axis-color handling in the positions diagram with a single index ↔ ProjectionAxis ↔ "xyz" array. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0828866 commit caa4987

4 files changed

Lines changed: 297 additions & 455 deletions

File tree

Crystallography.Controls/Crystal/SymmetryDiagramCommon.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,19 @@ protected readonly record struct Projection(ProjectionAxis Axis, string HorzLabe
8888
/// <summary>結晶座標 (u,v,w) を投影面 (Sx, Sy) に写像 (C: Sx=v, Sy=u 等)。</summary>
8989
protected static (double Sx, double Sy) ProjectVector(double u, double v, double w, ProjectionAxis axis) => axis switch
9090
{
91-
ProjectionAxis.C => (v, u), ProjectionAxis.A => (w, v), ProjectionAxis.B => (u, w), _ => (0, 0),
91+
ProjectionAxis.C => (v, u),
92+
ProjectionAxis.A => (w, v),
93+
ProjectionAxis.B => (u, w),
94+
_ => (0, 0),
95+
};
96+
97+
/// <summary>(260503Ch) 投影 depth 成分だけを返す。</summary>
98+
protected static double ProjectedDepth(double x, double y, double z, ProjectionAxis axis) => axis switch
99+
{
100+
ProjectionAxis.C => z,
101+
ProjectionAxis.A => x,
102+
ProjectionAxis.B => y,
103+
_ => 0,
92104
};
93105
#endregion
94106

@@ -166,6 +178,20 @@ protected static void DrawCellAndAxes(Graphics g, CellLayout c, Projection proj,
166178
#region 共通ユーティリティ
167179
protected static double Mod1(double x) => x - Math.Floor(x);
168180

181+
/// <summary>(260503Ch) 単位胞境界上の点を、表示セルと隣接セルの両方へ複製するための代表列。
182+
/// 内部点は 1 点だけ、境界近傍点は 3×3 のうち描画範囲に入るコピーだけを返す。</summary>
183+
protected static IEnumerable<(double Sx, double Sy)> EdgeReplicatedPoints(double sx, double sy)
184+
{
185+
bool nearEdge = Math.Min(sx, 1 - sx) < EdgeReplicate || Math.Min(sy, 1 - sy) < EdgeReplicate;
186+
for (int dx = -1; dx <= 1; dx++) for (int dy = -1; dy <= 1; dy++)
187+
{
188+
if ((dx != 0 || dy != 0) && !nearEdge) continue;
189+
double x = sx + dx, y = sy + dy;
190+
if (x >= -EdgeReplicate && x <= 1 + EdgeReplicate && y >= -EdgeReplicate && y <= 1 + EdgeReplicate)
191+
yield return (x, y);
192+
}
193+
}
194+
169195
/// <summary>0 < frac < 1 の典型分数ラベル。0 近傍は null。</summary>
170196
protected static string HeightLabel(double sz)
171197
{

0 commit comments

Comments
 (0)