2
$\begingroup$

I want to label each point of a Graphics3D with the simplest method as possible.

I tried many solutions like this :

 Manipulate[
  α ∈ Reals; A1 = {-1, 0, 1}; A2 = {Cos[α], Sin[2 α], -2};
  With[{polyw = PolyhedronData[poly, "Polyhedron"]}, 
   Graphics3D[{PointSize[0.03], 
    Map[{Text[Style[SymbolName[Unevaluated[#]]], RGBColor[Abs[#] // Round], 1.1 #], 
       Style[Point[#], RGBColor[Abs[Round[#]]]]} &, {A1, A2, B1, B2}],         
    MapIndexed[Text[#2[[1]], #] &, PolyhedronCoordinates[polyw]], 
    polyw}]], 
  {α, 0, Pi}, {poly, "Cube"}
]

But the variable # is evalute before the function Unevaluate

So I would like to know if there are a simple method to print the name of the variable (I have many, many points to enable in the graphic).

Maybe by using Information[] ?

$\endgroup$
  • 1
    $\begingroup$ As an aside, your first line inside the Manipulate Element[alpha, Reals] does nothing for you. You should include it in the global $Assumptions or wrap thinks in Assuming, or use the Assumptions -> option for functions that have it. $\endgroup$ – MarcoB May 24 at 15:18
  • $\begingroup$ B1, B2 are not defined in your code. You also have an odd Style[SymbolName[Unevaluated[#]]] within your Text: that's a call to Style without any styling directives, so it won't do much for you. More in general, can you simplify your code to a MUCH simpler minimal working example that gives rise to the same problem? For instance, what features do you want to label, and which labels do you want to use for each feature? $\endgroup$ – MarcoB May 24 at 15:48
2
$\begingroup$

Enter values as strings and convert to expressions.

EDIT: Added Opacity control

Manipulate[
 A1 = {-1, 0, 1};
 A2 = {Cos[α], Sin[2 α], -2};
 With[
  {polyw = PolyhedronData[poly, "Polyhedron"]},
  Graphics3D[{
    PointSize[0.03],
    Map[{
       RGBColor @@ Abs[#[[2]] // Round],
       Text[#[[1]], #[[2]], {1.5, 1.5}],
       Point[#[[2]]]} &,
     Thread[{#, ToExpression@#}] &@{"A1", "A2"}],
    MapIndexed[
     Text[#2[[1]], #] &,
     PolyhedronCoordinates[polyw]],
    {Opacity[opac], polyw}}]],
 {{α, 1.}, 0, Pi, 0.01, Appearance -> "Labeled"},
 {{opac, 0.5, "Opacity"}, 0, 1, 0.05,
  Appearance -> "Labeled"},
 {{poly, "Cube", Polyhedron},
  PolyhedronData["Platonic"],
  ControlType -> PopupMenu}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much @Bob for your answer. But I am very surprise that an software as efficient and developed as this does not have a very simple method for doing an very very simple action and very useful !!! Could someone tell me why Wolfram does not apparently want to include such a method in the build ? $\endgroup$ – oli mat May 25 at 8:15

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.