このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
centroid
polyshape
の重心
説明
例
多角形の重心
複数の領域がある多角形に関連付けられた重心を計算します。
2 つの固体領域をもつ多角形を作成し、その重心を計算します。
x1 = [0 1 2]; y1 = [0 1 0]; x2 = [2 3 4]; y2 = [1 2 1]; polyin = polyshape({x1,x2},{y1,y2}); [x,y] = centroid(polyin); plot(polyin) hold on plot(x,y,'r*') hold off
各領域の重心を個別に計算するには、2 番目の引数で各領域の境界インデックスを指定します。
[x,y] = centroid(polyin,[1 2]); plot(polyin) hold on plot(x(1),y(1),'r*',x(2),y(2),'r*') hold off
あるいは、最初に領域を個別の polyshape
オブジェクトに分離して各領域の重心を計算することもできます。関数 regions
を使用して、polyshape
オブジェクトの配列を作成します。この配列の各要素は、三角形領域のうちの 1 つを定義する polyshape
です。
polyarray = regions(polyin)
polyarray = 2x1 polyshape array with properties: Vertices NumRegions NumHoles
[x,y] = centroid(polyarray)
x = 2×1
1
3
y = 2×1
0.3333
1.3333
入力引数
polyin
— 入力 polyshape
スカラー | ベクトル | 行列 | 多次元配列
入力 polyshape
。スカラー、ベクトル、行列または多次元配列として指定します。
データ型: polyshape
I
— 境界インデックス
スカラー整数 | 整数のベクトル
境界インデックス。スカラー整数または整数のベクトルとして指定します。I
の各要素は、入力 polyshape
の 1 つの境界に対応します。
データ型: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
出力引数
x
— x 座標
スカラー | ベクトル | 行列 | 多次元配列
polyshape
の重心の x 座標。スカラー、ベクトル、行列または多次元配列として返されます。入力が polyshape
オブジェクトの配列である場合、x
には各 polyshape
の重心の x 座標が含まれます。
y
— y 座標
スカラー | ベクトル | 行列 | 多次元配列
polyshape
の重心の y 座標。スカラー、ベクトル、行列または多次元配列として返されます。入力が polyshape
オブジェクトの配列である場合、y
には各 polyshape
の重心の y 座標が含まれます。
バージョン履歴
R2017b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)