2
$\begingroup$

Consider the following lists:

coor = {{2.99535, 1.14412, 1.41421}, {2.55834, 2.28825, 0.707107}, {2.28825, 0.707107, 2.55834}, {1.14412, 1.41421, 2.99535}, {1.41421, 2.99535, 1.14412}, {3.43237, 0, 0.707107}, {0.707107, 2.55834, 2.28825}, {3.43237, 0, -0.707107}, {2.55834, 2.28825, -0.707107}, {2.28825, -0.707107, 2.55834}, {2.99535, 1.14412, -1.41421}, {1.14412, -1.41421, 2.99535}, {0, 0.707107, 3.43237}, {0.707107, 3.43237, 0}, {2.99535, -1.14412, 1.41421}, {0, -0.707107, 3.43237}, {-0.707107, 3.43237, 0}, {2.55834, -2.28825, 0.707107}, {-0.707107, 2.55834, 2.28825}, {2.99535, -1.14412, -1.41421}, {1.41421, 2.99535, -1.14412}, {-1.41421, 2.99535, 1.14412}, {2.55834, -2.28825, -0.707107}, {0.707107, 2.55834, -2.28825}, {2.28825, 0.707107, -2.55834}, {0.707107, -2.55834, 2.28825}, {-1.14412, 1.41421, 2.99535}, {1.14412, 1.41421, -2.99535}, {1.41421, -2.99535, 1.14412}, {-2.28825, 0.707107, 2.55834},{-1.14412, -1.41421, 2.99535}, {-1.41421, 2.99535, -1.14412}, {2.28825, -0.707107, -2.55834}, {-2.28825, -0.707107, 2.55834}, {-0.707107, 2.55834, -2.28825}, {1.14412, -1.41421, -2.99535}, {-2.55834, 2.28825, 0.707107}, {1.41421, -2.99535, -1.14412}, {-0.707107, -2.55834, 2.28825}, {-2.99535, 1.14412, 1.41421}, {0.707107, -2.55834, -2.28825}, {-1.41421, -2.99535, 1.14412}, {0, 0.707107, -3.43237}, {0.707107, -3.43237, 0}, {-2.55834, 2.28825, -0.707107}, {0, -0.707107, -3.43237}, {-0.707107, -3.43237, 0}, {-2.99535, 1.14412, -1.41421}, {-2.99535, -1.14412, 1.41421}, {-1.14412, 1.41421, -2.99535}, {-2.55834, -2.28825, 0.707107}, {-2.28825, 0.707107, -2.55834}, {-3.43237, 0, 0.707107}, {-0.707107, -2.55834, -2.28825}, {-3.43237, 0, -0.707107}, {-1.41421, -2.99535, -1.14412}, {-1.14412, -1.41421, -2.99535}, {-2.28825, -0.707107, -2.55834}, {-2.55834, -2.28825, -0.707107}, {-2.99535, -1.14412, -1.41421}};
edges = {{{2.55834, 2.28825, 0.707107}, {2.99535, 1.14412, 1.41421}}, {{2.28825, 0.707107, 2.55834}, {2.99535, 1.14412, 1.41421}}, {{2.99535, 1.14412, 1.41421}, {3.43237, 0, 0.707107}}, {{1.41421, 2.99535, 1.14412}, {2.55834, 2.28825, 0.707107}}, {{2.55834, 2.28825, -0.707107}, {2.55834, 2.28825, 0.707107}}, {{1.14412, 1.41421, 2.99535}, {2.28825, 0.707107,2.55834}}, {{2.28825, -0.707107, 2.55834}, {2.28825, 0.707107, 2.55834}}, {{0.707107, 2.55834, 2.28825}, {1.14412, 1.41421, 2.99535}}, {{0, 0.707107, 3.43237}, {1.14412, 1.41421, 2.99535}}, {{0.707107, 2.55834, 2.28825}, {1.41421, 2.99535, 1.14412}}, {{0.707107, 3.43237, 0}, {1.41421, 2.99535, 1.14412}}, {{3.43237, 0, -0.707107}, {3.43237, 0, 0.707107}}, {{2.99535, -1.14412, 1.41421}, {3.43237, 0, 0.707107}}, {{-0.707107, 2.55834, 2.28825}, {0.707107, 2.55834, 2.28825}}, {{2.99535, 1.14412, -1.41421}, {3.43237, 0, -0.707107}}, {{2.99535, -1.14412, -1.41421}, {3.43237, 0, -0.707107}}, {{2.55834, 2.28825, -0.707107}, {2.99535, 1.14412, -1.41421}}, {{1.41421, 2.99535, -1.14412}, {2.55834, 2.28825, -0.707107}}, {{1.14412, -1.41421, 2.99535}, {2.28825, -0.707107, 2.55834}}, {{2.28825, -0.707107, 2.55834}, {2.99535, -1.14412, 1.41421}}, {{2.28825, 0.707107, -2.55834}, {2.99535, 1.14412, -1.41421}}, {{0, -0.707107, 3.43237}, {1.14412, -1.41421, 2.99535}}, {{0.707107, -2.55834, 2.28825}, {1.14412, -1.41421, 2.99535}}, {{0, -0.707107, 3.43237}, {0, 0.707107, 3.43237}}, {{-1.14412, 1.41421, 2.99535}, {0, 0.707107, 3.43237}}, {{-0.707107, 3.43237, 0}, {0.707107, 3.43237, 0}}, {{0.707107, 3.43237, 0}, {1.41421, 2.99535, -1.14412}}, {{2.55834, -2.28825, 0.707107}, {2.99535, -1.14412, 1.41421}}, {{-1.14412, -1.41421, 2.99535}, {0, -0.707107, 3.43237}}, {{-1.41421, 2.99535, 1.14412}, {-0.707107, 3.43237, 0}}, {{-1.41421, 2.99535, -1.14412}, {-0.707107, 3.43237, 0}}, {{2.55834, -2.28825, 0.707107}, {2.55834, -2.28825, -0.707107}}, {{1.41421, -2.99535, 1.14412}, {2.55834, -2.28825, 0.707107}}, {{-1.41421, 2.99535, 1.14412}, {-0.707107, 2.55834, 2.28825}}, {{-1.14412, 1.41421, 2.99535}, {-0.707107, 2.55834, 2.28825}}, {{2.55834, -2.28825, -0.707107}, {2.99535, -1.14412, -1.41421}}, {{2.28825, -0.707107, -2.55834}, {2.99535, -1.14412, -1.41421}}, {{0.707107, 2.55834, -2.28825}, {1.41421, 2.99535, -1.14412}}, {{-2.55834, 2.28825, 0.707107}, {-1.41421, 2.99535, 1.14412}}, {{1.41421, -2.99535, -1.14412}, {2.55834, -2.28825, -0.707107}}, {{0.707107, 2.55834, -2.28825}, {1.14412, 1.41421, -2.99535}}, {{-0.707107, 2.55834, -2.28825}, {0.707107, 2.55834, -2.28825}}, {{1.14412, 1.41421, -2.99535}, {2.28825, 0.707107, -2.55834}}, {{2.28825, -0.707107, -2.55834}, {2.28825, 0.707107, -2.55834}}, {{0.707107, -2.55834, 2.28825}, {1.41421, -2.99535, 1.14412}}, {{-0.707107, -2.55834, 2.28825}, {0.707107, -2.55834, 2.28825}}, {{-2.28825, 0.707107, 2.55834}, {-1.14412, 1.41421, 2.99535}}, {{0, 0.707107, -3.43237}, {1.14412, 1.41421, -2.99535}}, {{0.707107, -3.43237, 0}, {1.41421, -2.99535, 1.14412}}, {{-2.28825, -0.707107, 2.55834}, {-2.28825, 0.707107, 2.55834}}, {{-2.99535, 1.14412, 1.41421}, {-2.28825, 0.707107, 2.55834}}, {{-2.28825, -0.707107, 2.55834}, {-1.14412, -1.41421, 2.99535}}, {{-1.14412, -1.41421, 2.99535}, {-0.707107, -2.55834, 2.28825}}, {{-1.41421, 2.99535, -1.14412}, {-0.707107, 2.55834, -2.28825}}, {{-2.55834, 2.28825, -0.707107}, {-1.41421, 2.99535, -1.14412}}, {{1.14412, -1.41421, -2.99535}, {2.28825, -0.707107, -2.55834}}, {{-2.99535, -1.14412, 1.41421}, {-2.28825, -0.707107, 2.55834}}, {{-1.14412, 1.41421, -2.99535}, {-0.707107, 2.55834, -2.28825}}, {{0.707107, -2.55834, -2.28825}, {1.14412, -1.41421, -2.99535}}, {{0, -0.707107, -3.43237}, {1.14412, -1.41421, -2.99535}}, {{-2.99535, 1.14412, 1.41421}, {-2.55834, 2.28825, 0.707107}}, {{-2.55834, 2.28825, 0.707107}, {-2.55834, 2.28825, -0.707107}}, {{0.707107, -2.55834, -2.28825}, {1.41421, -2.99535, -1.14412}}, {{0.707107, -3.43237, 0}, {1.41421, -2.99535, -1.14412}}, {{-1.41421, -2.99535, 1.14412}, {-0.707107, -2.55834, 2.28825}}, {{-3.43237, 0, 0.707107}, {-2.99535, 1.14412, 1.41421}}, {{-0.707107, -2.55834, -2.28825}, {0.707107, -2.55834, -2.28825}}, {{-1.41421, -2.99535, 1.14412}, {-0.707107, -3.43237, 0}}, {{-2.55834, -2.28825, 0.707107}, {-1.41421, -2.99535, 1.14412}}, {{0, -0.707107, -3.43237}, {0, 0.707107, -3.43237}}, {{-1.14412, 1.41421, -2.99535}, {0, 0.707107, -3.43237}}, {{-0.707107, -3.43237, 0}, {0.707107, -3.43237, 0}}, {{-2.99535, 1.14412, -1.41421}, {-2.55834, 2.28825, -0.707107}}, {{-1.14412, -1.41421, -2.99535}, {0, -0.707107, -3.43237}}, {{-1.41421, -2.99535, -1.14412}, {-0.707107, -3.43237, 0}}, {{-2.99535, 1.14412, -1.41421}, {-2.28825, 0.707107, -2.55834}}, {{-3.43237, 0, -0.707107}, {-2.99535, 1.14412, -1.41421}}, {{-2.99535, -1.14412, 1.41421}, {-2.55834, -2.28825, 0.707107}}, {{-3.43237, 0, 0.707107}, {-2.99535, -1.14412, 1.41421}}, {{-2.28825, 0.707107, -2.55834}, {-1.14412, 1.41421, -2.99535}}, {{-2.55834, -2.28825, -0.707107}, {-2.55834, -2.28825, 0.707107}}, {{-2.28825, -0.707107, -2.55834}, {-2.28825, 0.707107, -2.55834}}, {{-3.43237, 0, -0.707107}, {-3.43237, 0, 0.707107}}, {{-1.41421, -2.99535, -1.14412}, {-0.707107, -2.55834, -2.28825}}, {{-1.14412, -1.41421, -2.99535}, {-0.707107, -2.55834, -2.28825}}, {{-3.43237, 0, -0.707107}, {-2.99535, -1.14412, -1.41421}}, {{-2.55834, -2.28825, -0.707107}, {-1.41421, -2.99535, -1.14412}}, {{-2.28825, -0.707107, -2.55834}, {-1.14412, -1.41421, -2.99535}}, {{-2.99535, -1.14412, -1.41421}, {-2.28825, -0.707107, -2.55834}}, {{-2.99535, -1.14412, -1.41421}, {-2.55834, -2.28825, -0.707107}}};

where coor is the list of vertices of a polytope and edges is the list of its edges. I would like to generate a Graphics3D whose back edges are dashed, and those front are solid. I have previously tried this solution, but it doesn't work as I only use lines and vertices, and no surface (this solution gives me only solid edges).

My second approach was to separate the space into two regions and to classify the edges as if they were in front of or behind a plane. The edges that cross this plane are cut to give a dashed edge and a solid edge. Here is the code and the result obtained for the given lists:

pointOfView = {1.2728823621935175, -2.3966390529217407, 2.021358885014492};
frontList = {};
backList = {};
sorter[edge_, region_, plan_] := 
  Module[{pt1Member = RegionMember[region, edge[[1]]], 
    pt2Member = RegionMember[region, edge[[2]]], midpoint},
   If[pt1Member != pt2Member, 
    midpoint = RegionIntersection[plan, Line[{edge[[1]], edge[[2]]}]][[1]],Indeterminate
     ];
   Which[
    pt1Member == pt2Member == False, AppendTo[frontList, edge],
    pt1Member == pt2Member == True, AppendTo[backList, edge],
    pt1Member == True && pt2Member == False, AppendTo[backList, {edge[[1]], midpoint}] && AppendTo[frontList, {edge[[2]], midpoint}],
    pt1Member == False && pt2Member == True, AppendTo[frontList, {edge[[1]], midpoint}] && AppendTo[backList, {edge[[2]], midpoint}]
    ];
   ];
splitEdges[list_, ptOfView_] := 
  Module[{backRegion = HalfSpace[ptOfView, {0, 0, 0}], midplan},
   midplan = RegionBoundary[backRegion];
   Do[sorter[list[[i]], backRegion, midplan], {i, Length@list}];
   ];
splitEdges[edges, pointOfView];
Graphics3D[{Point[coor], {Dashed, Line[backList]}, {Thickness[0.003], 
   Line[frontList]}}, ViewPoint -> pointOfView, Boxed -> False]

The result is almost perfect, but I had not thought to edges behind the plan, but not behind the polytope (see the edge designated by the red arrow).

Exemple of the second approach.

So I appeal to your lights. Would anyone have an idea of how I could succeed in making these graphics without surfaces? I cannot use PolyhedronData because I have to stay general and my inputs are lists of vertices and edges.

$\endgroup$
1
$\begingroup$

Maybe you can use something like this in order to find polygons to glue in. Then you could use Silvia's method.

σ = AssociationThread[coor -> Range[Length[coor]]];
elist = Partition[Lookup[σ, Flatten[edges, 1]], 2];
G = Graph[elist];
polygons = Join[
 FindCycle[G, 5, All][[All, All, 1]], 
 FindCycle[G, 6, All][[All, All, 1]]
 ];
plot = Graphics3D[
  {EdgeForm[Thick], FaceForm[White],
   GraphicsComplex[coor, Polygon[polygons]]
   },
  Lighting -> "Neutral"
  ]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you, it works when I add this graphic to the one I already had. $\endgroup$ – physicien May 25 '18 at 1:03
  • $\begingroup$ That's good to hear! You're welcome. $\endgroup$ – Henrik Schumacher May 25 '18 at 7:12

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.