Message Boards Message Boards

0
|
3961 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

What 'primitives' in the documentation on Graphics3D stands for ?

As the examples in the documentation show, a list of Graphics3D primitives is OK. However, this list seems to require 'literal' primitives or directives such as 'Red' or 'Green'. Expressions that evaluate to primitives or directives such as If[x > 0, Red, Green] seem not to work.

My code which shows malfunctions here is quite complicated and it would be not easy to bring it in a demonstrable form. So, at least to start the discussion, I would like ask whether somebody in our community came across the problem and has an answer off hand.

POSTED BY: Ulrich Mutze
2 Replies

This works for me:

x = -1;
Graphics3D[{If[x > 0, Red, Green], Sphere[]}]
POSTED BY: Sander Huisman

You could also do this, in the case x is symbolic:

Graphics3D[{If[x > 0, Red, Green, {}], Sphere[]}]

notice the extra {}. This is for the case if x is not known yet, it will evaluate the If to something so Graphics3D can interpret it.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract