HalfSpace
Details
- HalfSpace can be used as a geometric region and a graphics primitive.
- HalfSpace corresponds to half-line or half-infinite interval in
, a half-plane in
, etc. - HalfSpace represents the set
or
. - HalfSpace can be used in Graphics and Graphics3D.
- HalfSpace will be clipped by PlotRange when rendering.
- Graphics rendering is affected by directives such as FaceForm, EdgeForm, Opacity, and color.
- Graphics3D rendering is affected by directives such as Opacity and color.
Examples
open all close allBasic Examples (3)
A HalfSpace in 2D:
Graphics[HalfSpace[{2, 1}, {0, 0}]]Graphics3D[HalfSpace[{-1, -1, 1}, {0, 0, 0}]]Different styles applied to a half-space region:
ℛ = HalfSpace[{-1, -1, 1}, {0, 0, 0}];{Graphics3D[{Pink, ℛ}], Graphics3D[{EdgeForm[Thick], Pink, ℛ}], Graphics3D[{EdgeForm[Dashed], Pink, ℛ}], Graphics3D[{EdgeForm[Directive[Thick, Dashed, Blue]], Pink, ℛ}]}Determine if points belong to a given half-space region:
ℛ = HalfSpace[{-1, -1, 1}, {0, 0, 0}];{RegionMember[ℛ, {1, 1, 1}], RegionMember[ℛ, {-1, 0, 0}]}Scope (15)
Graphics (5)
Specification (2)
A half-space in 2D defined by a normal vector and a point:
ill = Graphics[{PointSize[Medium], Point[{{0, 0}}], Arrowheads[Medium], Thick, Arrow[{{0, 0}, {-1, 1}}]}, PlotRange -> 2, Axes -> True];Show[Graphics[{Blue, HalfSpace[{-1, 1}, {0, 0}]}], ill, PlotRange -> 2]The same half-space defined by a normal vector and a constant:
ill = Graphics[{Arrowheads[Medium], Thick, Arrow[{{0, 0}, {-1, 1}}]}, PlotRange -> 2, Axes -> True];Show[Graphics[{Blue, HalfSpace[{-1, 1}, 0]}], ill, PlotRange -> 2]Define a half-space in 3D using a normal vector and a point:
ill = Graphics3D[{PointSize[Medium], Point[{1, 0, 2}], Arrowheads[Medium], Thick, Arrow[{{1, 0, 2}, {-1, 0, 2}}]}, PlotRange -> 2, Axes -> True];Show[ill, Graphics3D[HalfSpace[{-1, 0, 0}, {1, 0, 2}]]]Define the same half-space using a normal vector and a constant:
ill = Graphics3D[{Arrowheads[Medium], Thick, Arrow[{{1, 0, 2}, {-1, 0, 2}}]}, PlotRange -> 2, Axes -> True];Show[ill, Graphics3D[HalfSpace[{-1, 0, 0}, -1]]]Half-spaces varying in direction of the normal:
Table[Graphics3D[HalfSpace[{0, Cos[θ], Sin[θ]}, 0], ImageSize -> Tiny, PlotLabel -> θ], {θ, 0, π, π / 4}]Styling (2)
Color directives specify the color of the half-space:
Table[Graphics3D[{c, HalfSpace[{1, -1, 1}, 0]}], {c, {Red, Green, Yellow, Blue}}]FaceForm and EdgeForm can be used to specify the styles of the faces and edges:
Graphics3D[{FaceForm[Pink], EdgeForm[Directive[Dashed, Thick, Blue]], HalfSpace[{1, -1, 1}, 0]}]Coordinates (1)
Points and vectors can be Dynamic:
DynamicModule[{θ = 0}, {Slider[Dynamic[θ], {0, Pi}], Graphics3D[HalfSpace[Dynamic[{1, Cos[θ], Sin[θ]}], 0]]}]Regions (10)
Embedding dimension is the dimension of the coordinates:
RegionEmbeddingDimension[HalfSpace[{Subscript[x, 0], Subscript[y, 0], Subscript[z, 0]}, c]]RegionEmbeddingDimension[HalfSpace[{Subscript[x, 0], Subscript[y, 0]}, c]]Geometric dimension is the dimension of the region itself:
RegionDimension[HalfSpace[{Subscript[x, 0], Subscript[y, 0], Subscript[z, 0]}, c]]RegionDimension[HalfSpace[{Subscript[x, 0], Subscript[y, 0]}, c]]ℛ = HalfSpace[{1, 0, 0}, 0];{RegionMember[ℛ, {2, 2, 0}], RegionMember[ℛ, {0, 0, 1}]}Get the conditions for membership:
RegionMember[ℛ, {x, y, z}]A half-space has infinite measure and undefined centroid:
ℛ = HalfSpace[{1, 1}, 0];RegionMeasure[ℛ]RegionCentroid[ℛ]ℛ = HalfSpace[{1, 0}, -1];RegionDistance[ℛ, {-5, -3}]SignedRegionDistance[ℛ, {-5, -3}]ℛ = HalfSpace[{1, 1, 1}, 0];RegionNearest[ℛ, {1, 2, 3}]pts = Flatten[Table[{Cos[k 2 π / 8]Cos[j π / 8], Sin[k 2 π / 8]Cos[j π / 8], Sin[j π / 8]}, {k, 0, 7}, {j, -3, 3}], 1];
nst = RegionNearest[ℛ, #]& /@ pts;Legended[Graphics3D[{{Opacity[0.5], ℛ}, {Thin, Gray, Line[Transpose[{pts, nst}]]}, {Red, Point[pts]}, {Blue, Point[nst]}}, Boxed -> False], PointLegend[{Red, Blue}, {"start", "nearest"}]]ℛ = HalfSpace[{Subscript[x, 0], Subscript[y, 0], Subscript[z, 0]}, c];BoundedRegionQ[ℛ]RegionBounds[ℛ]ℛ = HalfSpace[{1, 0, 0}, 1];BoundedRegionQ[ℛ]RegionBounds[ℛ]ℛ = HalfSpace[{1, 0}, 0];Integrate[Exp[-x^2 - y^2], {x, y}∈ℛ]ℛ = HalfSpace[{1, 1, 1}, -4];Minimize[{x^2 + y^2 + z^2 + 1, {x, y, z}∈ℛ}, {x, y, z}]Solve equations over a half-space:
ℛ = HalfSpace[{1, 0, 0}, 0];Reduce[x^2 + y^2 + z^2 == 1 && {x, y, z}∈ℛ, {x, y, z}]Applications (5)
showHalfPlane[ahs_HalfSpace] := Graphics[{Opacity[0.3], ahs}, PlotRange -> {{-2, 2}, {-2, 2}}, Frame -> True]HalfSpace[{0, -1}, 0]//showHalfPlaneHalfSpace[{0, 1}, 0]//showHalfPlaneHalfSpace[{1, 0}, 0]//showHalfPlaneHalfSpace[{-1, 0}, 0]//showHalfPlaneshowHalfSpace[ahs_HalfSpace] := Graphics3D[{EdgeForm[White], Opacity[0.3], ahs}, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]HalfSpace[{0, 0, -1}, 0]//showHalfSpaceHalfSpace[{0, 0, 1}, 0]//showHalfSpaceHalfSpace[{1, 0, 0}, 0]//showHalfSpaceHalfSpace[{-1, 0, 0}, 0]//showHalfSpaceHalfSpace[{0, 1, 0}, 0]//showHalfSpaceHalfSpace[{0, -1, 0}, 0]//showHalfSpacePartition space in a BubbleChart:
b = BubbleChart3D[RandomReal[1, {20, 4}]];hs = HalfSpace[{1, 0, 1}, {0.5, 0, 0.5}];Show[b, Graphics3D[{Opacity[0.5], hs}]]Any convex polygon in 2D can be represented as an intersection of half-spaces:
Region[RegionIntersection@@(HalfSpace[#, 1]& /@ CirclePoints[6])]Any convex polyhedron in 3D can be represented as an intersection of half-spaces:
Region[RegionIntersection@@(HalfSpace[#, #]& /@ Tuples[{{-1, 1}, {-1, 1}, {-1, 1}}])]Properties & Relations (7)
ClipPlanes, for a given
, results in a graphic that does not render anything within the
:
{Graphics3D[HalfSpace[{1, 1, 1}, 1], PlotRange -> 1], Graphics3D[Cuboid[{-1, -1, -1}, {1, 1, 1}], ClipPlanes -> {1, 1, 1, -1}, PlotRange -> 1]}HalfSpace is a special case of ConicHullRegion:
p = {1, 2, 1};n = {-2, 3, 1};
v = NullSpace[{n}];Subscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = ConicHullRegion[p, v, {-n}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]HalfSpace is a special case of AffineHalfSpace:
p = {1, 2, 1};n = {-2, 3, 1};
v = NullSpace[{n}];Subscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = AffineHalfSpace[p, v, -n];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]HalfLine is a special case of HalfSpace:
Subscript[ℛ, 1] = HalfSpace[{-1}, {1}];
Subscript[ℛ, 2] = HalfLine[{1}, {1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]HalfPlane is a special case of HalfSpace:
Subscript[ℛ, 1] = HalfSpace[{-1, -1}, {1, 1}];
Subscript[ℛ, 2] = HalfPlane[{1, 1}, {1, -1}, {1, 1}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]ImplicitRegion can represent any HalfSpace in
:
p = {1};n = {-1};
eqns = n.{x} ≤ n.pSubscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = ImplicitRegion[eqns, {x}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]p = {1, 1};n = {-1, 1};
eqns = n.{x, y} ≤ n.pSubscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = ImplicitRegion[eqns, {x, y}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]p = {5, 4, 3, 2, 1};n = {1, 2, 3, 2, 1};
eqns = n.{x1, x2, x3, x4, x5} ≤ n.pSubscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = ImplicitRegion[eqns, {x1, x2, x3, x4, x5}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]ParametricRegion can represent any HalfSpace in
:
Subscript[ℛ, 1] = HalfSpace[{-1}, {1}];
Subscript[ℛ, 2] = ParametricRegion[{a}, {{a, 1, Infinity}}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]p = {1, 1};n = {-1, 1};
{v} = NullSpace[{n}];Subscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = ParametricRegion[{1, 1} - a n + b v, {{a, 0, Infinity}, b}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]p = {5, 4, 3, 2, 1};n = {1, 2, 3, 2, 1};
{v1, v2, v3, v4} = NullSpace[{n}];Subscript[ℛ, 1] = HalfSpace[n, p];
Subscript[ℛ, 2] = ParametricRegion[p - a n + b v1 + c v2 + d v3 + e v4, {{a, 0, Infinity}, b, c, d, e}];RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]Neat Examples (1)
A collection of random half-spaces in
:
Table[Graphics[{EdgeForm[Black], {RandomColor[], HalfSpace[RandomReal[{-1, 1}, 2], RandomReal[]]}}, ImageSize -> 30, Frame -> True, FrameTicks -> False], {30}]Table[Graphics3D[{EdgeForm[Black], {RandomColor[], HalfSpace[RandomReal[{-1, 1}, 3], RandomReal[]]}}, ImageSize -> 30, Boxed -> True, Ticks -> False], {20}]See Also
Related Guides
History
Text
Wolfram Research (2015), HalfSpace, Wolfram Language function, https://reference.wolfram.com/language/ref/HalfSpace.html.
CMS
Wolfram Language. 2015. "HalfSpace." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HalfSpace.html.
APA
Wolfram Language. (2015). HalfSpace. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HalfSpace.html
BibTeX
@misc{reference.wolfram_2026_halfspace, author="Wolfram Research", title="{HalfSpace}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/HalfSpace.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_halfspace, organization={Wolfram Research}, title={HalfSpace}, year={2015}, url={https://reference.wolfram.com/language/ref/HalfSpace.html}, note=[Accessed: 12-June-2026]}