0
$\begingroup$

As we know,t1*p1 + t2*p2 + t3*p3 is a triangle region whose vertice is {p1,p2,p3} when t1+t2+t3==1 and 0<t1<1&&0<t2<1&&0<t3<1.But I don't know how to draw this triangle?I just can estimate it with some points like

SeedRandom[2]
{p1, p2, p3} = RandomReal[1, {3, 3}];
t = Normalize[#, Total] & /@ RandomReal[1, {400, 3}];
Graphics3D[{PointSize[.02], 
  Point[Dot @@@ Tuples[{t, {{p1, p2, p3}}}]], Red, 
  Point[{p1, p2, p3}]}]

Mathematica graphics

But how to plot it with a shape?If I use ParametricRegion,it will be a parallelogram

Region@ParametricRegion[
   t1*p1 + t2*p2 + (1 - t1 - t2)*p3, {{t1, 0, 1}, {t2, 0, 1}}]~Show~
 Graphics3D[{PointSize[.02], Point /@ {p1, p2, p3}}]

How to implement it?

$\endgroup$
  • 1
    $\begingroup$ You need RegionFunction for plotting in barycentric coordinates: ParametricPlot3D[{u, v, 1 - u - v}.{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}, {u, 0, 1}, {v, 0, 1}, RegionFunction -> Function[{x, y, z, u, v}, u + v <= 1]] $\endgroup$ – J. M. will be back soon Apr 3 '17 at 17:46
  • $\begingroup$ @J.M. Thanks,I think it deseve an answer,and I will open it to wait other solution. $\endgroup$ – yode Apr 3 '17 at 17:53
  • 1
    $\begingroup$ Why not just Region[Simplex[{p1,p2,p3}]? $\endgroup$ – kglr Apr 3 '17 at 22:40
  • $\begingroup$ @kglr Fun,I just guess that t1+t2+t3==1 is a triangle,and want to plot it to comfirm.If I change it into t1+t2+t3==2,you cannot use Simplex anymore. :) $\endgroup$ – yode Apr 3 '17 at 22:52
  • 1
    $\begingroup$ Or Graphics3D[Polygon[{p1,p2,p3,p1}]] $\endgroup$ – David G. Stork Apr 3 '17 at 23:17
4
$\begingroup$

Perhaps:

reg[p1_, p2_, p3_] := 
 Show[ParametricPlot3D[{u, v, 1 - u - v}.{p1, p2, p3}, {u, 0, 1}, {v, 
    0, 1 - u}, Mesh -> None], 
  Graphics3D[{Red, PointSize[0.04], Point[{p1, p2, p3}]}]]

e.g.

Grid[Partition[reg @@@ RandomInteger[10, {9, 3, 3}], 3]]

enter image description here

David G. Stork (in the comments) points out: Polygon[{p1,p2,p3}] or Triangle[{p1,p2,p3}are simpler options.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.