Message Boards Message Boards

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

How to colour random 3D points in a stereographic view

I am trying to produce stereographic pics which give the impression of depth when viewed with the crossed-eye view technique. Basically I put two 2D projections of the 3D object next to each other, projected with two slightly different viewing angles. A piece of a code yielding such a double plot, showing particles randomly placed in space, reads like this:

pts = Table[
  Point[{RandomReal[], RandomReal[], RandomReal[]}], {20}]; TableView[
 Show[Graphics3D[{PointSize[0.05], pts}, ImageSize -> 300, 
   ViewPoint -> {2, -3.3, 2.5}]], 
 Show[Graphics3D[{PointSize[0.05], pts}, ImageSize -> 300, 
   ViewPoint -> {2, -3.5, 2.5}]]]

The result looks as

Random points in space

My question is: how can I choose a different colour for each point (in any way, either randomly or systematically) so that each point has a different colour in one figure, but each of them has the same colour in the second plot as in the first?

Imre Pazsit

POSTED BY: Imre Pazsit
2 Replies

With Mathematica 10 you can give each point a color of its own with pts = Table[{RandomColor[], Point[{RandomReal[], RandomReal[], RandomReal[]}]}, {20}];

In earlier version you may have to type a little more: pts = Table[{RGBColor[RandomReal[], RandomReal[], RandomReal[]], Point[{RandomReal[], RandomReal[], RandomReal[]}]}, {20}];

POSTED BY: Gianluca Gorni

Thanks - this is perfect! Exactly what I was looking for. Works beautifully.

POSTED BY: Imre Pazsit
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