draw_rhombohedral_cells プログラム仕様
六方格子(Hexagonal)と菱面体格子(Rhombohedral)の幾何学的関係を可視化するモジュール。
- 概要:
このスクリプトは、六方格子の基本ベクトル a1, a2, a3 を定義し、 変換行列 T を用いて菱面体格子の基本ベクトル r1, r2, r3 へ変換します。 変換後の格子ベクトルおよび単位格子を 3D 空間上に描画し、両者の関係を視覚化します。
- 詳細説明:
このスクリプトは以下の手順で処理を実行します。 1. 六方格子の軸長 aH, cH に基づき、直交座標系での格子ベクトルを生成します。 2. 六方→菱面体の変換行列 T を適用し、菱面体格子の基底を計算します。 3. 3D 矢印(Arrow3D クラス)を用いて格子ベクトルを描画します。 4. 平行六面体(単位格子)を描画し、空間的な重なりを示します。
- 変換式:
菱面体格子ベクトルを Rrhombo、六方格子ベクトルを Ahex とすると、 Rrhombo = T @ Ahex で表されます。
- class crystal.draw_rhombohedral_cells.Arrow3D(xs, ys, zs, *args, **kwargs)
ベースクラス:
FancyArrowPatch- 概要:
3D空間に矢印を描画するためのmatplotlib拡張クラスです。
- 詳細説明:
matplotlib.patches.FancyArrowPatch を継承し、 3D座標を受け取って2D投影された矢印として描画します。 主に draw メソッドと do_3d_projection メソッドが3D描画のためにオーバーライドされています。
- 引数:
- param xs:
矢印のX座標のリストまたはタプル (開始点X, 終了点X)。
- type xs:
list or tuple
- param ys:
矢印のY座標のリストまたはタプル (開始点Y, 終了点Y)。
- type ys:
list or tuple
- param zs:
矢印のZ座標のリストまたはタプル (開始点Z, 終了点Z)。
- type zs:
list or tuple
- param args:
FancyArrowPatch に渡される追加の位置引数。
- param kwargs:
FancyArrowPatch に渡される追加のキーワード引数。
- do_3d_projection(renderer=None)
- draw(renderer)
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (.Artist.get_visible returns False).
- パラメータ:
renderer (~matplotlib.backend_bases.RendererBase subclass.)
メモ
This method is overridden in the Artist subclasses.
- 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>, edgegapcolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, hatchcolor=<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.
a.set(a=A, b=B, c=C)
is equivalent to
a.set_a(A) a.set_b(B) a.set_c(C)
In addition to the full property names, aliases are also supported, e.g.
set(lw=2)is equivalent toset(linewidth=2), but it is an error to pass both simultaneously.The order of the individual setter calls matches the order of parameters in
set(). However, most properties do not depend on each other so that order is rarely relevant.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 edgegapcolor: :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 hatchcolor: :mpltype:`color` or 'edge' or None in_layout: bool joinstyle: .JoinStyle or {'miter', 'round', 'bevel'} label: object linestyle or ls: {'-', '--', '-.', ':', '', ...} or (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
- crystal.draw_rhombohedral_cells.draw_unit_cell(ax, origin, v1, v2, v3, color='black', lw=0.5)
- 概要:
指定された3つのベクトルに基づいて平行六面体(単位格子)を描画します。
- 詳細説明:
原点 origin から始まり、3つの基底ベクトル v1, v2, v3 で定義される 平行六面体の全ての辺を描画します。これにより単位格子が可視化されます。
- 引数:
- param ax:
描画対象の3D Axesオブジェクト。
- type ax:
mpl_toolkits.mplot3d.axes3d.Axes3D
- param origin:
格子の原点座標。
- type origin:
numpy.ndarray
- param v1:
単位格子を構成する第一のベクトル。
- type v1:
numpy.ndarray
- param v2:
単位格子を構成する第二のベクトル。
- type v2:
numpy.ndarray
- param v3:
単位格子を構成する第三のベクトル。
- type v3:
numpy.ndarray
- param color:
描画する線の色。デフォルトは 'black'。
- type color:
str
- param lw:
描画する線の太さ。デフォルトは 0.5。
- type lw:
float
- crystal.draw_rhombohedral_cells.draw_vector(ax, vec, color, label, fontsize)
- 概要:
3D空間にベクトル(矢印)とそのラベルを描画します。
- 詳細説明:
指定されたベクトルを原点 (0,0,0) から開始する矢印として Axes オブジェクト ax に追加します。 矢印の終点付近に、指定されたラベルを配置します。
- 引数:
- param ax:
描画対象の3D Axesオブジェクト。
- type ax:
mpl_toolkits.mplot3d.axes3d.Axes3D
- param vec:
描画するベクトルの終点座標。原点 (0,0,0) から開始します。
- type vec:
numpy.ndarray
- param color:
矢印とラベルの色。
- type color:
str
- param label:
ベクトルに表示するテキストラベル。
- type label:
str
- param fontsize:
ラベルのフォントサイズ。
- type fontsize:
int or float
- crystal.draw_rhombohedral_cells.main()
- 概要:
格子変換の計算と描画を実行するメインルーチンです。
- 詳細説明:
六方格子の軸長を定義し、六方格子ベクトルと格子点を計算します。 その後、六方→菱面体の変換行列を適用して菱面体格子ベクトルと格子点を導出します。 最後に、matplotlib を使用してこれらの格子ベクトルと単位格子を3D空間に描画し、 六方格子の外郭も表示して、両格子の関係性を視覚的に示します。