RegionNearestFunction[reg,…]
値が領域 reg 内の最近点を与える関数を表す.
RegionNearestFunction
RegionNearestFunction[reg,…]
値が領域 reg 内の最近点を与える関数を表す.
詳細
- RegionNearestFunctionはFunctionのように働く.
- RegionNearestFunctionはRegionNearest[reg]によって生成される.
- RegionNearestFunction[reg,…][p]はNorm[p-q]を最小化する点 q∈reg を与える.
例題
すべて開く すべて閉じる例 (1)
nf = RegionNearest[Disk[]]pts = Tuples[Range[-2, 2], 2];
Short[nf[pts]]Legended[Graphics[{{LightBlue, EdgeForm[Gray], Disk[]}, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]スコープ (16)
特別な領域 (7)
Point集合:
RegionNearest[Point[{{1, 1}, {1, 2}}]][{3, 4}]RegionNearest[Point[{{0, 0, 0, 0}, {1, 2, 3, 4}}]][{2, 2, 2, 2}]ℛ = Point[{{1, 2}, {3, 4}, {5, 6}}];
pts = Table[{3, 4} + 4{Cos[k 2π / 16], Sin[k 2π / 16]}, {k, 0, 15}];
nf = RegionNearest[ℛ];Legended[Graphics[{ℛ, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]Line:
RegionNearest[Line[{{0, 0}, {1, 1}}]][{3, 4}]RegionNearest[Line[{{0, 0, 0}, {1, 1, 1}, {0, 0, 1}}]][{1, 0, 3}]ℛ = Line[{{0, 0}, {1, 2}, {1, 0}, {2, 2}}];
pts = Table[{1, 1} + 2{Cos[k 2π / 16], Sin[k 2π / 16]}, {k, 0, 15}];
nf = RegionNearest[ℛ];Legended[Graphics[{ℛ, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]Rectangleは2Dで使うことができる:
RegionNearest[Rectangle[{0, 0}, {1, 2}]][{3, 4}]Cuboidは,これを任意の次元に一般化する:
RegionNearest[Cuboid[{0, 0, 0, 0}, {1, 2, 3, 4}]][{1, 1, 1, 5}]ℛ = Rectangle[{0, 0}, {2, 1}];
pts = Table[{1, 1 / 2} + 2{Cos[k 2π / 16], Sin[k 2π / 16]}, {k, 0, 15}];
nf = RegionNearest[ℛ];Legended[Graphics[{{LightBlue, EdgeForm[Gray], ℛ}, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]RegionNearest[Simplex[1]][{2}]RegionNearest[Simplex[3]][{1, 1, 1}]ℛ = Simplex[2];
pts = Table[{1 / 3, 1 / 3} + {Cos[k 2π / 16], Sin[k 2π / 16]}, {k, 0, 15}];
nf = RegionNearest[ℛ];Legended[Graphics[{{LightBlue, EdgeForm[Gray], ℛ}, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]RegionNearest[Polygon[{{0, 0}, {1, 0}, {0, 1}}]][{1, 1}]ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];
pts = Table[4{Cos[k 2 π / 25], Sin[k 2π / 25]}, {k, 0., 24}];
nf = RegionNearest[ℛ];Legended[Graphics[{{LightBlue, EdgeForm[Gray], ℛ}, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]Diskは2Dで使うことができる:
RegionNearest[Disk[{0, 0}, 1]][{3, 4}]Ballは,任意次元の円板を一般化する:
RegionNearest[Ball[{0, 0, 0}, 1]][{3, 4, 5}]ℛ = Ball[{0, 0, 0}, 1];
pts = Flatten[Table[2{Cos[k 2π / 8]Cos[l π / 8], Sin[k 2π / 8]Cos[l π / 8], Sin[l π / 8]}, {k, 0, 7}, {l, -3, 3}], 1];
nf = RegionNearest[ℛ];Legended[Graphics3D[{{LightBlue, EdgeForm[Gray], ℛ}, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]Diskは2Dでは楕円形のこともある:
RegionNearest[Disk[{0, 0}, {1, 2}]][{0, 4}]Ellipsoidを一般化すると任意次元の楕円形になる:
RegionNearest[Ellipsoid[{0, 0, 0}, {1, 2, 3}]][{0, 3, 4}]ℛ = Disk[{0, 0}, {2, 1}];
pts = Table[3{Cos[k 2π / 16], Sin[k 2π / 16]}, {k, 0., 15}];
nf = RegionNearest[ℛ];Legended[Graphics[{{LightBlue, EdgeForm[Gray], ℛ}, {Thin, Gray, Line[Transpose[{pts, nf[pts]}]]}, {Red, Point[pts]}, {Blue, Point[nf[pts]]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]数式定義領域 (2)
ImplicitRegionとして表された円板上の最近点:
ℛ = ImplicitRegion[x^2 + y^2 ≤ 1, {x, y}];Region[ℛ]nf = RegionNearest[ℛ]nf /@ RandomReal[1, {5, 2}]ℛ = ImplicitRegion[x^2 + y^2 ≤ 1, {x, y, {z, 0, 2}}];RegionNearest[ℛ][{3, 4, 5}]ParametricRegionとして表された円板上の最近点:
ℛ = ParametricRegion[{r Cos[θ], r Sin[θ]}, {{r, 0, 1}, {θ, 0, 2π}}];nf = RegionNearest[ℛ]nf /@ RandomReal[1, {5, 2}]ℛ = ParametricRegion[{r(1 - t^2/1 + t^2), r(2t/1 + t^2)}, {t, {r, 0, 1}}];RegionNearest[ℛ][{3, 4}]ℛ = ParametricRegion[{r Cos[θ], r Sin[θ], z}, {{r, 0, 1}, {θ, 0, 2π}, {z, 0, 2}}];RegionNearest[ℛ][{3, 4, 5}]FullSimplify[%]メッシュ領域 (4)
1DのBoundaryMeshRegion中の最近点:
ℛ = BoundaryMeshRegion[{{0}, {1}}, Point[{{1}, {2}}]]RegionNearest[ℛ][{2}]ℛ = ConvexHullMesh[RandomReal[1, {10, 2}]];Show[ℛ, Graphics[{Red, Point[{1, 1}]}]]RegionNearest[ℛ][{1, 1}]ℛ = ConvexHullMesh[RandomReal[1, {20, 3}]];Show[ℛ, Graphics3D[{Red, Point[{1, 1, 1}]}]]RegionNearest[ℛ][{1, 1, 1}]1D中の0DのMeshRegionの最近点:
ℛ = MeshRegion[{{0}, {1}}, Point[{{1}, {2}}]]RegionNearest[ℛ][{1 / 2}]ℛ = MeshRegion[{{0}, {1}}, Line[{1, 2}]]RegionNearest[ℛ][{2}]2D中の0DMeshRegion中の最近点:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Point[{{1}, {2}, {3}}]];Show[ℛ, Graphics[{Red, Point[{1, 1}]}]]RegionNearest[ℛ][{1, 1}]ℛ = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Line[{1, 2, 3, 1}]];Show[ℛ, Graphics[{Red, Point[{1, 1}]}]]RegionNearest[ℛ][{1, 1}]ℛ = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Polygon[{1, 2, 3}]];Show[ℛ, Graphics[{Red, Point[{1, 1}]}]]RegionNearest[ℛ][{1, 1}]3D中の0DMeshRegion中の最近点:
ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Point[{{1}, {2}, {3}, {4}}]];Show[ℛ, Graphics3D[{Red, Point[{1, 1, 1}]}]]RegionNearest[ℛ][{1, 1, 1}]ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Line[{{1, 2, 3, 4, 1}}]];Show[ℛ, Graphics3D[{Red, Point[{1, 1, 1}]}]]RegionNearest[ℛ][{1, 1, 1}]ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Polygon[{{1, 2, 3}, {2, 3, 4}}]];Show[ℛ, Graphics3D[{Red, Point[{1, 1, 1}]}]]RegionNearest[ℛ][{1, 1, 1}]ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Tetrahedron[{{1, 2, 3, 4}}]];Show[ℛ, Graphics3D[{Red, Point[{1, 1, 1}]}]]RegionNearest[ℛ][{1, 1, 1}]派生領域 (3)
RegionIntersectionまでの距離:
ℛ = RegionIntersection[Disk[{0, 0}, 1], Disk[{0, 1}, 1]];Show[Graphics[{Red, Point[{1, 1}]}], Region[ℛ]]RegionNearest[ℛ][{1, 1}]TransformedRegionまでの距離:
ℛ = TransformedRegion[Disk[], ScalingTransform[{3, 2}]];Show[Region[ℛ], Graphics[{Red, Point[{4, 3}]}]]RegionNearest[ℛ][{4, 3}]RegionBoundaryまでの距離:
ℛ = RegionBoundary[Disk[]];Graphics[{ℛ, Red, Point[{1 / 2, 1 / 2}]}]RegionNearest[ℛ][{1 / 2, 1 / 2}]アプリケーション (2)
ℛ = BoundaryDiscretizeRegion[ImplicitRegion[Abs[x]^1 / 2 + Abs[y]^1 / 2 ≤ 1, {x, y}], {{-1, 1}, {-1, 1}}];
nf = RegionNearest[ℛ];
pts = Flatten[Table[r{Cos[k 2π / 128], Sin[k 2π / 128]}, {k, 0, 127}, {r, 1, 2}], 1];
nst = nf[pts];Show[ℛ, Graphics[{Thin, Gray, Line[Transpose[{pts, nst}]]}]]Locatorを使って国の領域に対する最近点を求める:
ℛ = DiscretizeGraphics[CountryData["Italy", "Shape"]];nf = RegionNearest[ℛ]DynamicModule[{p = {0.05, 0.05}}, Show[ℛ, Graphics[{Locator[Dynamic[p]], Red, Dynamic@Line[{nf[p], p}]}, PlotRange -> RegionBounds[ℛ]]], SaveDefinitions -> True]特性と関係 (2)
RegionNearestFunctionは,点に適用された場合には,RegionNearest[r,p]と同じ結果を返す:
ℛ = Triangle[];
nf = RegionNearest[ℛ]pts = RandomReal[1, {100, 2}];nf[pts] == RegionNearest[ℛ, pts]RegionNearestに返された式は,点で評価されると,RegionNearestFunctionと同じになる:
ℛ = Circle[];
nf = RegionNearest[ℛ]pts = RandomReal[1, {100, 2}];f[{x_, y_}] = RegionNearest[ℛ, {x, y}]nf[pts] == f /@ pts考えられる問題 (1)
RegionNearestFunctionはConstantRegionQ領域についてのみ生成される:
c = Circle[{0, 0}, r];ConstantRegionQ[c]RegionNearest[c]関連するガイド
-
▪
- 領域の特性と測定
テキスト
Wolfram Research (2014), RegionNearestFunction, Wolfram言語関数, https://reference.wolfram.com/language/ref/RegionNearestFunction.html.
CMS
Wolfram Language. 2014. "RegionNearestFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegionNearestFunction.html.
APA
Wolfram Language. (2014). RegionNearestFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegionNearestFunction.html
BibTeX
@misc{reference.wolfram_2026_regionnearestfunction, author="Wolfram Research", title="{RegionNearestFunction}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/RegionNearestFunction.html}", note=[Accessed: 13-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_regionnearestfunction, organization={Wolfram Research}, title={RegionNearestFunction}, year={2014}, url={https://reference.wolfram.com/language/ref/RegionNearestFunction.html}, note=[Accessed: 13-November-2026]}