4
$\begingroup$

Is there a simple way to vary the line thickness relative to the viewpoint so as to add a sense of perspective? Take for example the following:

Manipulate[
 lines = Table[{RandomInteger[{-1, 1}] a, RandomInteger[{-1, 1}] a, 
    RandomInteger[{-1, 1}] a}, {2^a}]; 
 Graphics3D[Line[lines], Boxed -> False], {a, 1, 12, 1}]

enter image description here

which generates some lines projected in a 3-dimensional fashion with a clearly visible perspective i.e. the lines of similar length appears longer when closer to the viewer.

Since the information regarding apparent distance to the viewpoint is known to the system, it should be possible to retrieve this and modify the thickness of lines accordingly.

Is this possible in a simple manner? enter image description here

The sketch above illustrates my point, although somewhat clumsy.

$\endgroup$
4
  • 6
    $\begingroup$ How about Tube instead of Line? $\endgroup$
    – Michael E2
    Aug 21, 2014 at 18:37
  • $\begingroup$ I have never heard of tubes. I will check them out. $\endgroup$
    – MathLind
    Aug 21, 2014 at 18:47
  • 1
    $\begingroup$ Concerning "Since the information regarding apparent distance to the viewpoint is known to the system...": that is generally true of Mathematica but less so in the case of Graphics because the actual rendering is being done in the front end and not the kernel. $\endgroup$
    – mfvonh
    Aug 21, 2014 at 19:17
  • 1
    $\begingroup$ Not exactly what you asked for, but since you want to make the 3D arrangement of lines easier to see, this previous question may be useful. $\endgroup$
    – user484
    Aug 21, 2014 at 21:32

1 Answer 1

3
$\begingroup$

I agree with @MichaelE2, 3D rendered tube will improve 3D notion by light reflection via Specularity and plus some Opacity.

Manipulate[
 lines = Table[{RandomInteger[{-1, 1}] a, RandomInteger[{-1, 1}] a, 
    RandomInteger[{-1, 1}] a}, {2^a}];
 Graphics3D[{Orange, Opacity[.3], Specularity[White, 20], 
   Tube[lines, .05]}, Boxed -> False, Background -> Black], {{a, 7}, 
  1, 12, 1}]

enter image description here

3D graphs are naturally rendered like that - note how coloring of edges changes during rotation:

Graph3D[RandomGraph[{39, 65}]]

enter image description here

$\endgroup$
3
  • $\begingroup$ Nice examples Vitaliy. However the first one does increase the calculation time about 100-fold, which makes turning the object almost impossible. At least on my computer. $\endgroup$
    – MathLind
    Aug 22, 2014 at 6:59
  • $\begingroup$ @MathLind Try it without Opacity[0.3]. $\endgroup$
    – Michael E2
    Aug 22, 2014 at 10:49
  • $\begingroup$ @MichaelE2 Yes that made a huge difference. $\endgroup$
    – MathLind
    Aug 22, 2014 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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