draw_unit_cell プログラム仕様

単位格子を描画するスクリプト。

概要:

結晶学における単位格子を3Dで可視化する機能を提供します。

詳細説明:

任意の格子定数と角度から単位格子の形状を計算し、Matplotlibを使用して描画します。 基本ベクトル(a, b, c)の描画には、パースペクティブを考慮したカスタム3D矢印クラスを使用します。

関連リンク: 技術ドキュメント: draw_unit_cell.py

class jsap_crystal.draw_unit_cell.Arrow3D(xs, ys, zs, *args, **kwargs)[ソース]

ベースクラス: FancyArrowPatch

Matplotlibの3Dプロットでカスタムの3D矢印を描画するためのクラス。

詳細説明: FancyArrowPatch を継承し、3D空間内の座標を2Dスクリーン座標に変換して描画することで、 常に適切なパースペクティブで矢印が表示されるようにします。

do_3d_projection(renderer=None)[ソース]

3Dプロジェクションを実行し、矢印の深度を計算します。

詳細説明: 3D座標を2Dスクリーン座標に変換し、Z軸方向の最小値(深度)を返すことで、 3Dビューにおけるオブジェクトの描画順序を適切に管理します。 :param renderer: matplotlib.backend_bases.RendererBase: Matplotlibのレンダラーオブジェクト(オプション)。 :returns: numpy.float: 矢印のZ軸方向の最小値(深度)。

draw(renderer)[ソース]

矢印をレンダリングします。

詳細説明: 3D座標を2Dスクリーン座標に変換し、変換された座標を使用して矢印を描画します。 :param renderer: matplotlib.backend_bases.RendererBase: Matplotlibのレンダラーオブジェクト。 :returns: None

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Properties:

agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: float or None animated: bool antialiased or aa: bool or None arrowstyle: [ '-' | '<-' | '->' | '<->' | '<|-' | '-|>' | '<|-|>' | ']-' | '-[' | ']-[' | '|-|' | ']->' | '<-[' | 'simple' | 'fancy' | 'wedge' ] capstyle: .CapStyle or {'butt', 'projecting', 'round'} clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None color: :mpltype:`color` connectionstyle: [ 'arc3' | 'angle3' | 'angle' | 'arc' | 'bar' ] edgecolor or ec: :mpltype:`color` or None facecolor or fc: :mpltype:`color` or None figure: ~matplotlib.figure.Figure or ~matplotlib.figure.SubFigure fill: bool gid: str hatch: {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} hatch_linewidth: unknown in_layout: bool joinstyle: .JoinStyle or {'miter', 'round', 'bevel'} label: object linestyle or ls: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} linewidth or lw: float or None mouseover: bool mutation_aspect: float mutation_scale: float patchA: .patches.Patch patchB: .patches.Patch path_effects: list of .AbstractPathEffect picker: None or bool or float or callable positions: unknown rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float

jsap_crystal.draw_unit_cell.draw_unit_cell_plot(a, b, c, alpha, beta, gamma, elev=5.9, azim=-67.55, fontsize=24, color='blue')[ソース]

指定された格子定数と角度を持つ単位格子を3Dで描画します。

詳細説明: lattice_vectors 関数を使用して基本格子ベクトルを計算し、それらから単位格子の8つの頂点を生成します。 その後、Matplotlibを用いて単位格子の辺、頂点、および基本格子ベクトルを3D空間に描画します。

jsap_crystal.draw_unit_cell.draw_vector(ax, vec, color, label, fontsize)[ソース]

3D空間にベクトルと対応するラベルを描画します。

詳細説明: Arrow3D クラスを利用して、原点から指定されたベクトルまでの矢印を描画し、 ベクトルの先端にラベルを配置します。 :param ax: matplotlib.axes.Axes: 3DプロットのAxesオブジェクト。 :param vec: numpy.ndarray: 描画するベクトルの3D座標([x, y, z])。 :param color: str: 矢印とラベルの色。 :param label: str: ベクトルに付けるラベル。 :param fontsize: int: ラベルのフォントサイズ。 :returns: None

jsap_crystal.draw_unit_cell.lattice_vectors(a, b, c, alpha, beta, gamma)[ソース]

格子定数と角度から基本格子ベクトルを計算します。

詳細説明: 結晶学で用いられる格子定数 (a, b, c) と軸間角 (alpha, beta, gamma) を用いて、 直交座標系における3つの基本格子ベクトル (va, vb, vc) を計算します。 :param a: float: 格子定数aの長さ。 :param b: float: 格子定数bの長さ。 :param c: float: 格子定数cの長さ。 :param alpha: float: b軸とc軸の間の角度(度数)。 :param beta: float: a軸とc軸の間の角度(度数)。 :param gamma: float: a軸とb軸の間の角度(度数)。 :returns: tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]: 3つの基本格子ベクトル (va, vb, vc)。各ベクトルは [x, y, z] の形式の numpy.ndarray

jsap_crystal.draw_unit_cell.main()[ソース]

メインの実行ルーチン。特定の格子定数で単位格子を描画します。

jsap_crystal.draw_unit_cell.set_equal_aspect(ax, points)[ソース]

3Dプロットのアスペクト比を均等に設定し、描画範囲を調整します。

詳細説明: 描画される点の最大・最小座標に基づいて、X, Y, Z軸の表示範囲を同じにします。 :param ax: matplotlib.axes.Axes: 3DプロットのAxesオブジェクト。 :param points: numpy.ndarray: 描画される全ての点のNumpy配列。形状は (N, 3)。 :returns: None