Download (as "sq_sleeve.pm") sq_sleeve.pm
# -*- mode: perl -*-
package sq_sleeve;
use GDS2;
use strict;
use POSIX qw(floor ceil);
use Getopt::Std;
use Math::Trig;
require './arc.pm'; # 円弧座標(の組)を計算して返す
require './text2gds.pm';
# ---------------------------------
# arc::arc(中心 x, 中心 y, 開始角, 終了角, 半径, 頂点の数,
# 'not-used', 時計回り(-1) or 反時計回り(1) )
# ---------------------------------
my($VERSION);
$VERSION = "2018-11-12 18:38" ; # written by emacs time-stamp
# global variable, ここで宣言すると、 sub の中からも見える
my $pi = 3.141592;
sub rotate ($$$) {
my ($x) = shift;
my ($y) = shift;
my ($angle) = shift; # in degree
# ------------------------------------------------
# X cos(theta) -sin(theta) x
# =
# Y sin(theta) cos(theta) y
# ------------------------------------------------
my ($theta) = $angle * 3.14159265 /180;
## https://mathwords.net/heimenkaiten
my ($X) = $x * cos($theta) + $y * - sin($theta);
my ($Y) = $x * sin($theta) + $y * cos($theta);
return ($X, $Y);
}
# ------------------------------------------------
# CP のstructure を作る
# ------------------------------------------------
sub SqSIPHA ($$$) {
my $S = shift; # nm
my $angle = shift;
my $gds2File = shift;
my $name = sprintf("SqSIPHA%dW%dnm", $angle, $S);
my $W = $S/1000; # --- nanometer to micron
my $H = $S/1000;
$gds2File -> printBgnstr (-name => $name);
$gds2File -> printBoundary (
-xy=> [
rotate(-$W/2, -$H/2, $angle),
rotate( $W/2, -$H/2, $angle),
rotate( $W/2, $H/2, $angle),
rotate(-$W/2, $H/2, $angle)],
);
$gds2File -> printEndstr();
return $name;
}
# ------------------------------------------------------
# 90 度毎のふちどり 100nm の正方形でふちどり
# ------------------------------------------------------
sub arcCP ($$$$$ $$$$){
my $x = shift;
my $y = shift;
my $start = shift;
my $end = shift;
my $step = shift; # --- angle step
my $size = shift; # --- CP 四角形の大きさ 0.1 等
my $diameter = shift;
my $extra_count = shift; # --- 周囲に配置する CP の数に追加
my $gds2File = shift;
my $outer_length = ( $diameter - $size ) * $pi / 4 + $extra_count ; # ---- 90 度分
my $outer_count = int($outer_length/ $size);
my $angle_pitch = 360/$outer_count;
# -------------------------------------------------------
# 円の内側と外側(から $size /2 だけ外に出た曲線)の座標を用意する
# -------------------------------------------------------
my @COORDS = arc::arc($x, $y, $start, $end, ($diameter + $size)/2, $outer_count, '', 1);
# ------------------------------------------------------
# structure 開始
# ------------------------------------------------------
my $structure = sprintf("100nm-%ddeg-%4.1fum-A%03d", $step, $diameter + $outer_length, $start);
$structure = sprintf("100nm-%ddeg-%4.1fum-A%03d", $step, $diameter , $start);
$gds2File -> printBgnstr( -name=> $structure);
# -----------------------------------
# 外側部分
# -----------------------------------
# 「配置点の数 * 2 = 座標の数」、配置点の数で繰返
foreach my $i ( 0 .. $#COORDS/2) { # $#variable は (@variable の個数 - 1) を表わす
# my $structure;
# -------------------------------------------------------------------
# 座標は x1, y1, x2, y2 と並んでいるので、 x と y を一つおきに取出して組で使う
# -------------------------------------------------------------------
my ($x) = $COORDS[$i * 2];
my ($y) = $COORDS[$i * 2 + 1];
my $angle = atan($y/$x) * 180/$pi;
my $angle_round;
$angle_round = int (($angle+$step/2)%90/$step)* $step;
$gds2File -> printSref(
-name => sprintf("SqSIPHA%dW100nm", $angle_round),
-xy => [$x, $y]);
my $string = sprintf("%03.1f -> %3.1f", $angle, $angle_round);
# text2gds::text_flat( $x, $y, 50, 0.002, $string, $gds2File);
}
$gds2File -> printEndstr;
return $structure;
}
1;
__END__
(require 'time-stamp)
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-active t)
;; (setq time-stamp-time-zone "UTC")
(setq time-stamp-time-zone nil)
(setq time-stamp-format "%04y-%02m-%02d %02H:%02M");
(setq time-stamp-start "$VERSION = \"") ;
(setq time-stamp-end "\"") ;
(setq time-stamp-line-limit 20) ; ; default is 8
|