2Dあるいは3Dのグラフィックス g をMeshRegionに離散化する.
DiscretizeGraphics[g,patt]
g 中のパターン patt にマッチする要素のみを離散化する.
DiscretizeGraphics
2Dあるいは3Dのグラフィックス g をMeshRegionに離散化する.
DiscretizeGraphics[g,patt]
g 中のパターン patt にマッチする要素のみを離散化する.
詳細とオプション
- DiscretizeGraphicsは,グラフィックスを,MeshRegionで使われる区分線形セルの不連続な和集合に離散化する.
- グラフィックス g は,Graphics,Graphics3Dあるいは個別のグラフィックスプリミティブでよい.
- DiscretizeGraphicsは,事実上,GraphicsおよびGraphics3D中の複数のプリミティブを和集合の操作として扱う.
- g が有界の区分線形プリミティブのみを含む場合は,離散化は厳密である.それ以外の場合は近似的である.
- 次は,厳密に表すことができるGraphics中の有界の区分的線形プリミティブである.
-
Point[…] 点 (0D) Line[…] 線 (1D) Triangle[…] 塗り潰された三角形 (2D) Polygon[…] 塗り潰された多角形 (2D) Rectangle[…] 塗り潰された長方形 (2D) Parallelogram[…] 塗り潰された平行四辺形 (0D,1Dあるいは2D) Simplex[…] 単体 (0D,1Dあるいは2D) - これらに加え,SSSTriangle,SASTriangle,ASATriangle,AASTriangleも評価するとTriangleになり,厳密に表すことができる.
- 次は,有限範囲のみを表すことができるGraphics中の非有界の区分線形プリミティブである.
-
HalfLine[…] 半線あるいは放射線 (1D) InfiniteLine[…] 無限線 (1D) HalfPlane[…] 半空間 (2D) ConicHullRegion[…] 線形円錐 (0D,1Dあるいは2D) - 次は,近似的にのみ表すことができるGraphicsの非線形プリミティブである.
-
Circle[…] 円,楕円,扇形(1D) Disk[…] 円板,塗り潰された楕円,扇形(2D) BezierCurve[…] ベジエスプライン曲線(1D) BSplineCurve[…] Bスプライン曲線(1D) JoinedCurve[…] 結合された曲線分(1D) FilledCurve[…] 塗り潰された閉じた曲線(2D) - 加えて,Circumsphereを評価するとSphereになり,近似的に表すことができる.
- 次は,厳密に表すことができるGraphics3Dの有界の区分線形プリミティブである.
-
Point[…] 点 (0D) Line[…] 線 (1D) Triangle[…] 塗り潰された三角形 (2D) Polygon[…] 塗り潰された多角形 (2D) Cuboid[…] 塗り潰された直方体 (3D) Parallelepiped[…] 塗り潰された平行六面体 (0D,1D,2D,あるいは3D) Tetrahedron[…] 塗り潰された四面体 (3D) Hexahedron[…] 塗り潰された六面体 (3D) Pyramid[…] 塗り潰された角錐 (3D) Prism[…] 塗り潰された角柱 (3D) Simplex[…] 単体 (0D,1D,2D,あるいは3D) - 次は,有限範囲のみを表すことができるGraphics3Dの非有界の区分線形プリミティブである.
-
HalfLine[…] 半直線あるいは放射線 (1D) InfiniteLine[…] 無限線 (1D) HalfPlane[…] 1方向に有界である平面 (2D) InfinitePlane[…] 無限平面 (3D) ConicHullRegion[…] 線形円錐 (0D,1D,2D,あるいは3D) - 次は,近似的にのみ表すことができるGraphics3Dの非線形プリミティブである.
-
BezierCurve[…] ベジエ曲線 (1D) BSplineCurve[…] Bスプライン曲線 (1D) JoinedCurve[…] 結合曲線分 (1D) BSplineSurface[…] Bスプライン曲面 (2D) Sphere[…] 球 (2D) Ball[…] 球体あるいは塗り潰された球 (3D) Ellipsoid[…] 塗り潰された楕円体 (3D) Cylinder[…] 塗り潰された円柱 (3D) Cone[…] 塗り潰された円錐 (3D) - 加えて,Circumsphereを評価するとSphereになるので,近似的に表すことができる.
- DiscretizeGraphicsには,MeshRegionと同じオプションに以下の追加・変更を加えたものが使える.
-
AccuracyGoal Automatic 目標確度 MaxCellMeasure Automatic 最大セル測度 MeshQualityGoal Automatic メッシュセルの品質目標 Method Automatic 使用するメソッド MeshRefinementFunction None メッシュをさらに分割する必要がある場合にTrueを返す関数 PlotRange Automatic 含める範囲 PerformanceGoal $PerformanceGoal スピードあるいは品質を考慮するかどうか PrecisionGoal Automatic 目標精度 - AccuracyGoal->a およびPrecisionGoal->p のときは,領域 reg あるいは離散化された領域 dreg とRegionSymmetricDifference[reg,dreg]の任意の点の間の距離を
未満に保とうと試みられる.ただし,
はプロット範囲の対角線の長さである.
例題
すべて開く すべて閉じる例 (3)
Circleを含む2Dの特別な領域を離散化する:
DiscretizeGraphics[Graphics[{Circle[]}]]DiscretizeGraphics[Graphics[{Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]}]]Coneを含む3Dの特別な領域を離散化する:
DiscretizeGraphics[Graphics3D[{Cone[]}]]DiscretizeGraphics[Graphics3D[{Prism[{{1, 0, 1}, {0, 0, 0}, {2, 0, 0}, {1, 2, 1}, {0, 2, 0}, {2, 2, 0}}]}]]2DのGraphicsシーン全体を離散化する.ここでは複数プリミティブが和集合として捉えられている:
DiscretizeGraphics[[image]]Area[%]スコープ (16)
Graphics (9)
Circleを含む2Dの特殊な領域を離散化する:
DiscretizeGraphics[Graphics[{Circle[]}]]DiscretizeGraphics[Graphics[{Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]}]]Point,Line,Polygonを含むGraphicsComplexのGraphicsを離散化する:
v = {{0, 0}, {3, 0}, {3, 3}, {0, 3}};g = Graphics /@ {GraphicsComplex[v, Point[{1, 2, 3, 4}]], GraphicsComplex[v, Line[{1, 2, 3, 4, 1}]], GraphicsComplex[v, Polygon[{1, 2, 3, 4}]]}DiscretizeGraphics /@ gRectangle,Circle,Diskを含むGraphicsComplexのGraphicsを離散化する:
v = {{0, 0}, {2, 0}, {2, 2}, {0, 2}};g = Graphics /@ {GraphicsComplex[v, Rectangle /@ {1, 2, 3, 4}], GraphicsComplex[v, Circle /@ {1, 2, 3, 4}], GraphicsComplex[v, Disk /@ {1, 2, 3, 4}]}DiscretizeGraphics /@ gg = Graphics[{Brown, Disk[{-1, 0}, 2], LightBlue, Rectangle[{0, -2}, {4, 2}], Red, Point[{6, 1}], Circle[{5, 0}, 2], Line[{{-4, 0}, {8, 0}}]}]DiscretizeGraphics[g, _Circle | _Rectangle]DiscretizeGraphics[g, x_ /; RegionDimension[x] < 2]すべての(All)プリミティブを離散化する:
DiscretizeGraphics[g, All]有界の区分線形Graphicsプリミティブは,厳密に表すことができる:
g = Graphics[{Orange, Triangle[{{-1, 1}, {0, 2}, {1, 1}}], Blue, Rectangle[{-1, 0}], Yellow, Simplex[2], Brown, Parallelogram[{2, 0}, {{-1, 0}, {-1, 1}}], Purple, Polygon[{{2, 1}, {4, 0}, {3, 1}, {4, 2}}]}]DiscretizeGraphics[g]非有界の区分線形Graphicsプリミティブは,有限範囲でのみ表すことができる:
p = {InfiniteLine[{0, 0}, {1, 1}], HalfLine[{0, 0}, {-1, 1}], HalfPlane[{{1, 0}, {2, 1}}, {1, -1}], ConicHullRegion[{{-1, 0}}, {{-1, -1}, {-1, 1}}]};g = Graphics[p, PlotRange -> {{-3, 3}, {-1.5, 1.5}}]DiscretizeGraphics[g]非線形Graphicsプリミティブは近似的にしか表すことができない:
g = Graphics[{BSplineCurve[{{0, 0}, {1, -1}, {2, -1}, {3, 0}, {4, -2}, {5, 0}}], Circle[{2, 1}]}]DiscretizeGraphics[g]GraphicsComplexを含むグラフィックス:
v = Table[15{Cos[t], Sin[t]}, {t, 0, 4Pi, 4Pi / 5}];g = Graphics[GraphicsComplex[v, {Orange, Line[{1, 4, 2, 5, 3, 1}], Polygon[{1, 2, 3, 4, 5}]}]]DiscretizeGraphics[g]MaxCellMeasureを使って離散化レベルを制御する:
g = Graphics[{Disk[{0, 0}], Circle[{1, 0}]}]Table[DiscretizeGraphics[g, MaxCellMeasure -> {"Length" -> m}], {m, {0.9, 0.6, 0.3}}]Graphics3D (7)
Coneを含む,3Dの特別な領域を離散化する:
DiscretizeGraphics[Graphics3D[{Cone[]}]]DiscretizeGraphics[Graphics3D[{Prism[{{1, 0, 1}, {0, 0, 0}, {2, 0, 0}, {1, 2, 1}, {0, 2, 0}, {2, 2, 0}}]}]]Point,Line,Polygonを含むGraphicsComplexのGraphics3Dを離散化する:
v = {{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}};
i = {{1, 2, 5}, {2, 3, 5}, {3, 4, 5}, {4, 1, 5}};g = Graphics3D /@ {GraphicsComplex[v, {PointSize@Large, Point[Range@5]}], GraphicsComplex[v, Line[i]], GraphicsComplex[v, Polygon[i]]}DiscretizeGraphics /@ g複数のプリミティブが和集合として解釈されるGraphics3Dシーン全体を離散化する:
DiscretizeGraphics[[image]]Volume[%]p = {Point[Tuples[{0, 1}, 3]], Table[Line[{{x, -0.5, 0}, {x, -2, 0}}], {x, 2, 6}],
Triangle[{{6, 0, 0}, {4.5, 0, 0}, {5, 2, 0}}], Cone[{{3, 1, 0}, {3, 1, 2}}]};g = Graphics3D[p, Boxed -> False]DiscretizeGraphics[g, _Line | _Cone]DiscretizeGraphics[g, x_ /; RegionDimension[x] < 2]すべての(All)プリミティブを離散化する:
DiscretizeGraphics[g, All]有界区分線形Graphics3Dプリミティブは,厳密に表すことができる:
p = {Point[{-3, 0, 0}], Line[{{-2.5, 0, 0}, {-1.5, 0, 0}}], Triangle[{{-1.2, 0, 0}, {-0.5, 0, 0}, {-1, 1, 0}}], Parallelepiped[{0, 0, 0}, {{1, 0, 0}, {1, 1, 0}, {0, 1, 1}}]};g = Graphics3D[p, Boxed -> False]DiscretizeGraphics[g]非有界Graphics3Dプリミティブは,有限範囲でしか表すことができない:
p = {InfiniteLine[{0, 0, 0}, {1, 0, 0}], HalfLine[{0, 0, 0}, {0, 0, -1}], InfinitePlane[{0, 0, -2}, {{1, 0, 0}, {0, 1, 0}}], HalfPlane[{{-1 / 2, 0, -2}, {-1 / 2, 1, -2}}, {-1, 0, 1}],
ConicHullRegion[{{0, 0, 0}}, {{1, 1, 0}, {0, 1, 1}, {1, 0, 1}}]};g = Graphics3D[p, Boxed -> False, PlotRange -> {{-3, 3}, {-3, 3}, {-6, 3}}]DiscretizeGraphics[g]非線形Graphics3Dプリミティブは,近似的にしか表すことができない:
g = Graphics3D[{Cylinder[{{2, 2, 0}, {2, 2, 2}}, 1], Sphere[{3, 3, 1}], BSplineSurface[Table[{i, j, RandomReal[{-1, 0}]}, {i, 5}, {j, 5}]]}]DiscretizeGraphics[g]オプション (24)
AccuracyGoal (1)
MaxCellMeasure (6)
mr = DiscretizeGraphics[Graphics[{Disk[{0, 0}], Circle[{1, 0}]}], MaxCellMeasure -> 0.1]AnnotationValue[{mr, 2}, MeshCellMeasure]g = Graphics3D[{Cylinder[{{2, 2, 0}, {2, 2, 2}}, 1], Sphere[{3, 3, 1}]}]mr = DiscretizeGraphics[g, MaxCellMeasure -> 0.1]セルの体積のHistogram:
Histogram[AnnotationValue[{mr, 3}, MeshCellMeasure]]g = Graphics[{Circle[{0, 0}], Circle[{1, 0}]}]Table[DiscretizeGraphics[g, MaxCellMeasure -> {"Length" -> m}], {m, {0.8, 0.1, 0.05}}]g = Graphics[{Disk[{0, 0}], Disk[{1, 0}]}]Table[DiscretizeGraphics[g, MaxCellMeasure -> {"Area" -> m}], {m, {0.4, 0.2, 0.05}}]g = Graphics3D[{Cylinder[{{2, 2, 0}, {2, 2, 2}}, 1], Sphere[{3, 3, 1}]}]Table[DiscretizeGraphics[g, MaxCellMeasure -> {"Area" -> m}], {m, {1, 0.1, 0.01}}]g = Graphics3D[{Ball[]}]Table[DiscretizeGraphics[g, MaxCellMeasure -> {"Volume" -> m}], {m, {0.3, 0.01, 0.001}}]MeshCellHighlight (2)
MeshCellHighlightを使うと,MeshRegionの一部をハイライトするように指定することができる:
DiscretizeGraphics[Graphics[Disk[]], MeshCellHighlight -> {{1, All} -> Red, {0, All} -> Green}]DiscretizeGraphics[Graphics[Line[{{{0, 0}, {1, 0}}, {{1, 0}, {2, 0}}}]], MeshCellHighlight -> {{1, 1} -> {Thick, Red}, {1, 2} -> {Dashed, Green}}]DiscretizeGraphics[Graphics[Line[{{{0, 0}, {1, 0}}, {{1, 0}, {2, 0}}}]], MeshCellHighlight -> {Line[{1, 2}] -> {Thick, Red}, Line[{2, 3}] -> {Dashed, Green}}]MeshCellLabel (3)
MeshCellLabelを使ってMeshRegionの一部にラベルを付けることができる:
DiscretizeGraphics[Graphics[Point[{{0, 0}, {1, 0}, {2, 0}}]], MeshCellLabel -> {0 -> "Index"}]DiscretizeGraphics[Graphics[{Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]}], MeshCellLabel -> {0 -> "Index", 1 -> "Index"}]DiscretizeGraphics[Graphics[Line[{{{0, 0}, {1, 0}}, {{1, 0}, {2, 0}}}]], MeshCellLabel -> {{1, 1} -> "x", {1, 2} -> "y"}]DiscretizeGraphics[Graphics[Line[{{{0, 0}, {1, 0}}, {{1, 0}, {2, 0}}}]], MeshCellLabel -> {Line[{1, 2}] -> "x", Line[{2, 3}] -> "y"}]MeshCellMarker (1)
MeshCellMarkerを使ってMeshRegionの一部に値を割り当てることができる:
DiscretizeGraphics[Graphics[Point[{{0, 0}, {1, 0}, {2, 0}}]], MeshCellMarker -> {{0, 1} -> 1, {0, 2} -> 2, {0, 3} -> 3}]MeshCellLabelを使ってマーカーを示す:
DiscretizeGraphics[Graphics[Point[{{0, 0}, {1, 0}, {2, 0}}]], MeshCellMarker -> {{0, 1} -> 1, {0, 2} -> 2, {0, 3} -> 3}, MeshCellLabel -> {0 -> "Marker"}]MeshCellShapeFunction (2)
MeshCellShapeFunctionを使うと,MeshRegionの一部についての関数を指定することができる:
DiscretizeGraphics[Graphics[Line[{{0, 0}, {2, 0}, {1, Sqrt[3]}, {0, 0}}]], MeshCellShapeFunction -> {0 -> (Disk[#, .1]&)}]DiscretizeGraphics[Graphics[Line[{{0, 0}, {2, 0}, {1, Sqrt[3]}, {0, 0}}]], MeshCellShapeFunction -> {{0, 1} -> (Disk[#, .1]&), {0, 2} -> (Disk[#, {.1, .2}]&)}]DiscretizeGraphics[Graphics[Line[{{0, 0}, {2, 0}, {1, Sqrt[3]}, {0, 0}}]], MeshCellShapeFunction -> {Point[1] -> (Disk[#, .1]&), Point[2] -> (Disk[#, {.1, .2}]&)}]MeshCellStyle (2)
MeshCellStyleを使うとMeshRegionの一部のスタイルを指定することができる:
DiscretizeGraphics[Graphics[Disk[]], MeshCellStyle -> {{1, All} -> Red, {0, All} -> Green}]DiscretizeGraphics[Graphics[Line[{{{0, 0}, {1, 0}}, {{1, 0}, {2, 0}}}]], MeshCellStyle -> {{1, 1} -> {Thick, Red}, {1, 2} -> {Dashed, Green}}]DiscretizeGraphics[Graphics[Line[{{{0, 0}, {1, 0}}, {{1, 0}, {2, 0}}}]], MeshCellStyle -> {Line[{1, 2}] -> {Thick, Red}, Line[{2, 3}] -> {Dashed, Green}}]PlotRange (4)
Automaticには,有限領域の全範囲が含まれる:
g = Graphics[{Triangle[], Circle[{-1, -1}]}];DiscretizeGraphics[g, PlotRange -> Automatic]Automaticは,無限領域の部分的範囲も含む:
g = Graphics[{HalfLine[{0, 0}, {-1, 1}], HalfPlane[{{1, 0}, {2, 1}}, {1, -1}]}];DiscretizeGraphics[g, PlotRange -> Automatic]g = Graphics[{Disk[{0, 0}], Circle[{1.5, 0}]}, PlotRange -> {{-1, 3}, {-1, 1}}]DiscretizeGraphics[g]DiscretizeGraphics[g, PlotRange -> {{0, 3}, {0, 1}}]g = Graphics[{Circle[], HalfPlane[{{1, 0}, {2, 1}}, {1, -1}]}];DiscretizeGraphics[g, PlotRange -> {{-3, 3}, {-3, 3}}]中空ではないプリミティブを切り取った結果は中空ではないプリミティブである.その他の場合は内側が露出される:
g = Graphics3D[{Ball[], Sphere[{2, 0, 0}]}]DiscretizeGraphics[g, PlotRange -> {{-1, 3}, {0.1, 1}, {-2, 2}}]PlotTheme (2)
DiscretizeGraphics[Graphics3D[Pyramid[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}}]], PlotTheme -> "Detailed"]DiscretizeGraphics[Graphics[Disk[]], PlotTheme -> "Detailed"]DiscretizeGraphics[Graphics3D[Pyramid[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}}]], PlotTheme -> "Lines"]DiscretizeGraphics[Graphics[Disk[]], PlotTheme -> "Lines"]PrecisionGoal (1)
PrecisionGoalの各設定の結果を比較する:
g = Graphics3D[{Cylinder[{{2, 2, 0}, {2, 2, 2}}, 1], Sphere[{3, 3, 1}]}]{mr2, mr3} = Table[DiscretizeGraphics[g, PrecisionGoal -> n], {n, {1, 3}}]アプリケーション (4)
g = KnotData["Trefoil", "KnotDiagram"];ℛ = DiscretizeGraphics[g]//QuietArcLength[ℛ]グラフィックスを幾何学領域に変換し,そのグラフィックスの表面積を計算する:
p = PolyhedronData["Dodecahedron"];ℛ = DiscretizeGraphics[p]Area[ℛ]Textを幾何学領域に変換する:
t = Text[Style["π", Bold]]DiscretizeGraphics[t, _Text, MaxCellMeasure -> 0.1]DiscretizeGraphics[CountryData["France", "Polygon"]]特性と関係 (9)
g = Graphics[{Rectangle[], Circle[], Line[{{1, -1}, {-1, 1}}]}]DiscretizeGraphics[g]g = Graphics[{Line[{{1, -1}, {-1, 1}}], Triangle[], Rectangle[{-1, -1}, {0, 0}]}]DiscretizeGraphics[g]g = Graphics[{InfiniteLine[{0, 0}, {1, 1}], HalfPlane[{{1, 0}, {2, 1}}, {1, -1}]}, PlotRange -> {{-1.5, 2.75}, {-1.5, 1.5}}]DiscretizeGraphics[g]g = Graphics[Table[Circle[{0, 0}, r], {r, {1, 4, 7}}]]DiscretizeGraphics[g]BoundaryDiscretizeGraphicsを使ってBoundaryMeshRegion表現を得る:
g = Graphics[{Brown, Disk[{1.5, 1}], Orange, Rectangle[]}]{br, mr} = {BoundaryDiscretizeGraphics[g], DiscretizeGraphics[g]}{BoundaryMeshRegionQ[br], MeshRegionQ[mr]}DiscretizeRegionを使って任意のRegionQオブジェクトを離散化することができる:
DiscretizeRegion[ImplicitRegion[x ^ 2 - y ^ 2 ≤ 1, {{x, -2, 2}, {y, -2, 2}}]]DiscretizeGraphicsを使って,GraphicsオブジェクトおよびGraphics3Dオブジェクトを離散化することができる:
DiscretizeGraphics[Graphics[{BezierCurve[{{0, 1}, {1, 1}, {2, -1}, {5, 1}}], Circle[]}]]両者はどちらも,グラフィックスプリミティブでもある特殊な領域を離散化することができる:
{DiscretizeRegion[Disk[]], DiscretizeGraphics[Disk[]]}幾何学領域でもあるグラフィックスプリミティブは,離散化なしに使うことができる:
r = Disk[{0, 0}, 1];RegionQ[r]Area[r]Area[DiscretizeGraphics[r]]Rasterizeは,描画された任意の式を離散化して,Rasterオブジェクトを含むGraphicsにする:
g = Graphics[{Disk[{0, 0}], Circle[{1, 0}]}]Rasterize[g, RasterSize -> {30, 20}, ImageSize -> 100]Imageは,描画された任意の式を離散化してImageオブジェクトにする:
g = Graphics[{Disk[{0, 0}], Circle[{1, 0}]}]Image[g, ImageSize -> {30, 20}, Magnification -> 4]関連するガイド
-
▪
- メッシュベースの幾何学的領域 ▪
- 幾何学的計算
テキスト
Wolfram Research (2014), DiscretizeGraphics, Wolfram言語関数, https://reference.wolfram.com/language/ref/DiscretizeGraphics.html (2015年に更新).
CMS
Wolfram Language. 2014. "DiscretizeGraphics." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/DiscretizeGraphics.html.
APA
Wolfram Language. (2014). DiscretizeGraphics. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiscretizeGraphics.html
BibTeX
@misc{reference.wolfram_2026_discretizegraphics, author="Wolfram Research", title="{DiscretizeGraphics}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/DiscretizeGraphics.html}", note=[Accessed: 08-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_discretizegraphics, organization={Wolfram Research}, title={DiscretizeGraphics}, year={2015}, url={https://reference.wolfram.com/language/ref/DiscretizeGraphics.html}, note=[Accessed: 08-September-2026]}