Skip to content

Instantly share code, notes, and snippets.

@shspage
shspage / ai_schwarz_christoffel_mapping.md
Last active August 7, 2022 19:35
an example of Schwarz-Christoffel mapping with Adobe Illustrator and python

Adobe Illustrator と python を使った Schwarz-Christoffel mapping の一例

Schwarz-Christoffel mapping という変換手法を使って、Illustrator でこんな図を作成してみました。

square_to_circle

以下の頁を参考にさせて頂きました。
http://squircular.blogspot.jp/2015/09/schwarz-christoffel-mapping.html
ただし、大きさや向きを変更するための計算は省いています。
計算方法などの詳しい説明は、上記頁からリンクしている PDF ファイルにあります。
中心になる式だけを書くと、変換後の座標を得る式はそれぞれ以下のようになります。

@shspage
shspage / area.png
Last active February 28, 2018 13:30
area.png
// Adobe Illustrator script
// 補間関数を使った図形の合成の実験。
// 2つの渦巻き。描画結果は折れ線
function main(){
var GAIN = 4; // シグモイド関数のゲイン
var T_MAX = 31; // 回転角度の最大値(radian)
var OFFSET = 20; // 始点と原点の距離
var STEP = 0.05; // 回転角度の増分
var EDGE = 1.6; // スムースステップ関数, cos補間の範囲上限値(下限は-EDGE)
@shspage
shspage / PoincareDiskInversion.jsx
Created April 19, 2017 11:49
Illustrator:ポアンカレ円板上での反転関連
// PoincareDiskInversion.jsxinc
// Gist上でシンタックスハイライトするためにファイル名を~jsxにしてます
var PoincareDiskInversion;
(function(){
// ------------------------
var STROKE_WIDTH = 0.5;
var STROKE_GRAY_VALUE = 100;
var MARK_RADIUS = 2;
@shspage
shspage / draw_arc.jsx
Last active October 3, 2017 21:47
Illustrator : 2点をつなぐ弧を描く
// 3つのオブジェクト(前面からp1, p2, o)が選択されているとき、
// p1の中心からp2の中心へ反時計回りに弧を描く。
// o の中心を弧の中心とする。
// ----------------------------------------------
// 点
// x, y : float
var Point = function(x, y){
this.x = x;
this.y = y;
}
@shspage
shspage / test_1point_and_2circles.jsx
Created April 11, 2017 11:38
Illustrator : 1点を通り2円に接する円を描く
// 1点を通り2円に接する円を描く
// (3円に接する円を描く、の改変版)
// 円の内側に接するケースも考えるともっと場合分けする必要がある
// 参考:http://www.comp.tmu.ac.jp/knotNRG/texfiles/apollonius.pdf
// ----------------------------------------------
// 点
function Point(x, y){ // x, y : float
this.x = x;
this.y = y;
}
@shspage
shspage / test_inverse1.jsx
Created April 9, 2017 08:07
Illustrator:最背面のパス(円)に関して残りの選択パスのアンカーポイントを反転変換した座標に移動する
// 最背面のパス(円)に関して残りの選択パスの
// アンカーポイントを反転変換した座標に移動する
// --------------------------------------
var Point = function(x, y){
this.x = x;
this.y = y;
}
Point.prototype = {
// anc : PathPoint.anchor
byAnchor : function(anc){
@shspage
shspage / sukimani_en_2.jsx
Last active April 10, 2017 21:56
Illustratorで3円に接する円を描く
// 3円に接する円を描く
// 円の内側に接するケースも考えるともっと場合分けする必要がある
// 参考:http://www.comp.tmu.ac.jp/knotNRG/texfiles/apollonius.pdf
// ----------------------------------------------
// 点
function Point(x, y){ // x, y : float
this.x = x;
this.y = y;
}
Point.prototype = {
@shspage
shspage / sessen_test1.jsx
Created April 1, 2017 01:16
Illustrator で2円をつなぐ線を描く
// 座標や範囲を配列で表すと見にくいのでクラスのようなものにします。
function Point(x, y){ // 点
this.x = x;
this.y = y;
}
function Rect(bounds){ // 範囲 bounds:[left, top, right, bottom]
this.left = bounds[0];
this.top = bounds[1];
this.right = bounds[2];
this.bottom = bounds[3];
@shspage
shspage / sukimani_en.jsx
Last active April 1, 2017 07:28
Illustrator script 3つの(半径が同じ)円の隙間に円を描く
// ----------------------------------------------
function Point(x, y){
this.x = x;
this.y = y;
}
// ----------------------------------------------
function Circle(path){ // path: PathItem(円とする)
var w = 0;
if(path.stroked) w = path.strokeWidth / 2;
this.center = new Point(