5
$\begingroup$

The following code plots the conic combination of 3 vectors in R^3 but it is undesirable since I need to tweak the inequalities by hand:

v1 = {1, 0.2, 0.2}; v2 = {0.2, 2, 0.2}; v3 = {0.2, 0.2, 3}; a = Graphics3D[Arrow[{{0, 0, 0}, #}] & /@ {v1, v2, v3}]; r = RegionPlot3D[ Cross[v1, v3].{x, y, z} <= 0 && Cross[v1, v2].{x, y, z} >= 0 && Cross[v2, v3].{x, y, z} >= 0, {x, 0, 5}, {y, 0, 5}, {z, 0, 5}, AxesLabel -> Automatic]; Show[r, a, BoxRatios -> Automatic] 

Is there any way to plot this more efficiently/neatly?

Thanks.

$\endgroup$
0

4 Answers 4

5
$\begingroup$

Looks like a case for ConicHullRegion: it produces a clean image almost instantly:

v = {{1, 0.2, 0.2}, {0.2, 2, 0.2}, {0.2, 0.2, 3}}; chr = ConicHullRegion[{{0, 0, 0}}, v]; Graphics3D[{Arrow[{{0, 0, 0}, #}] & /@ v, FaceForm @@ ({#, #}& @ {Opacity[.3], Red}), EdgeForm @ Blue, chr}, PlotRangePadding -> 0, Axes -> True, PlotRange -> Table[{0, 5}, 3]] 

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Excellent that command does a neat and clean job. I am wondering how I can obtain the same smooth results by using ImplicitRegion and LinearSolve (see answer below). Thanks. $\endgroup$ Commented Jan 6, 2022 at 0:21
5
$\begingroup$
v1 = {1, 0.2, 0.2}; v2 = {0.2, 2, 0.2}; v3 = {0.2, 0.2, 3}; 

Define an implicit region that satisfies your constraints:

V = Transpose[{v1, v2, v3}]; R = ImplicitRegion[Thread[LinearSolve[V, {x, y, z}] >= 0], {x, y, z}] (* ImplicitRegion[ 1.03186 (1. x - 0.0939597 y - 0.0604027 z) >= 0 && -0.0969529 (1. x - 5.28571 y + 0.285714 z) >= 0 && -0.0623269 (1. x + 0.444444 y - 5.44444 z) >= 0, {x, y, z}] *) RegionPlot3D[R, PlotPoints -> 100, Axes -> True, AxesLabel -> {x, y, z}] 

enter image description here

Alternatively, define a parametric region:

S = ParametricRegion[V . {a1, a2, a3}, {{a1, 0, ∞}, {a2, 0, ∞}, {a3, 0, ∞}}] (* ParametricRegion[{{a1 + 0.2 a2 + 0.2 a3, 0.2 a1 + 2 a2 + 0.2 a3, 0.2 a1 + 0.2 a2 + 3 a3}, a1 >= 0 && a2 >= 0 && a3 >= 0}, {a1, a2, a3}] 

and plot it in the same way.

$\endgroup$
2
  • $\begingroup$ Very interesting. How can I remove the sawtooth effect? Looks awful even using >100 points which takes quite some time to render. Thanks. $\endgroup$ Commented Jan 5, 2022 at 23:54
  • 1
    $\begingroup$ I'd recommend using @kglr's solution with ConicHullRegion. ConicHullRegion allows plotting with Graphics3D, which ImplicitRegion and ParametricRegion don't. $\endgroup$ Commented Jan 6, 2022 at 7:49
4
$\begingroup$

If this is good enough, you could create the convex hull like:

v1 = {1, 0.2, 0.2}; v2 = {0.2, 2, 0.2}; v3 = {0.2, 0.2, 3}; Region[ConvexHullRegion[{{0, 0, 0}, v1, v2, v3}], Axes -> True, Boxed -> True] 

enter image description here

If you want to show more of the infinite region, you may include sums of the given vectors like:

Region[ConvexHullRegion[{{0, 0, 0}, v1, v2, v3, v1 + v2, v1 + v3, v2 + v3, v1 + v2 + v3}], Axes -> True, Boxed -> True] 

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks for your answer. I have Mathematica v11.0 and it seems the command "ConvexHullRegion" is not defined. In fact, I was interested in programming a command like that one by using standard vector operations, which is done in the next answer. $\endgroup$ Commented Jan 5, 2022 at 22:48
3
$\begingroup$

RegionPlot3D can be slow, I think because each mesh point gets checked against the constraints. Setting terms for the cross products so that they only get calculated once speeds up the plotting by a factor of 15 on my system.

v1 = {1, 0.2, 0.2}; v2 = {0.2, 2, 0.2}; v3 = {0.2, 0.2, 3}; a = Graphics3D[Arrow[{{0, 0, 0}, #}] & /@ {v1, v2, v3}]; v1xv3 = Cross[v1, v3]; v1xv2 = Cross[v1, v2]; v2xv3 = Cross[v2, v3]; r = RegionPlot3D[ v1xv3 . {x, y, z} <= 0 && v1xv2 . {x, y, z} >= 0 && v2xv3 . {x, y, z} >= 0, {x, 0, 5}, {y, 0, 5}, {z, 0, 5}, PlotPoints -> 100, AxesLabel -> Automatic]; Show[r, a, BoxRatios -> Automatic] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.