MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: For[] command in Show[] function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41840] Re: For[] command in Show[] function
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 6 Jun 2003 09:51:19 -0400 (EDT)
  • References: <bbna7h$2aq$1@smc.vnet.net>
  • Reply-to: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Sender: owner-wri-mathgroup at wolfram.com

"Jong Choi" <jxc91 at po.cwru.edu> wrote in message
news:bbna7h$2aq$1 at smc.vnet.net...
> Dear All,
> I want to show the 18 points in the 3D space.
> So I used the Show[ ] function.
> But in every points, I should type the Point[position[i]] repeatly.
> If I can use the For[ ] routine, the code will be simple.
> Please let me know how to use For routine in the Show[ ] function or how
to
> show a lot of points in 3D space with simple codes.
> Thanks,
> Jong
>
>
> Code :
> position =
>     {
>       {-10, -13, 0}, {-12, -13, 0}, {-14, -13, 0}, {-16, -13, 0},
>       {-10, -13, -2}, {-12, -13, -2}, {-14, -13, -2}, {-16, -13, -2},
>       {-10, -13, -4}, {-12, -13, -4}, {-14, -13, -4}, {-16, -13, -4},
>       {-10, -13, -6}, {-12, -13, -6}, {-14, -13, -6}, {-16, -13, -6},
>       {-10, -13, -8}, {-12, -13, -8}};
> Show[Graphics3D[
>      {RGBColor[1, 0, 0], PointSize[0.04],
>       Point[position[[1]]], Point[position[[2]]], Point[position[[3]]] ,
>       Point[position[[4]]], Point[position[[5]]], Point[position[[6]]] ,
>       Point[position[[7]]], Point[position[[8]]], Point[position[[9]]] ,
>       Point[position[[10]]], Point[position[[11]]], Point[position[[12]]]
,
>       Point[position[[13]]], Point[position[[14]]], Point[position[[15]]]
,
>       Point[position[[16]]], Point[position[[17]]], Point[position[[18]]]
>      }]
>     ]
>
> Expected code : (not correct)
> Show[Graphics3D[For[i=1,i<19,Point[ position[[i]] ],i++]]];
>
>
> ================================
> Jongung Choi
> Biologically Inspired Robotics Laboratory
> Mechanical and Aerospace Engineering
> Case Western Reserve Univ.
> Cleveland, OH 44106-7222
> Phone:  216-368-5216
> Email: jxc91 at po.cwru.edu, jxc91 at hotmail.com
> Homepage: http://biorobots.cwru.edu/Personnel/jxc/index.html
>
---------------------------------------------------------------

Jong,
We can use For - I had to modify your use a little.
Notice that For itself returns Null - we have to arrange to extract the list
pts that is being constructed by adding ;pts.


position={{-10,-13,0},{-12,-13,0},{-14,-13,0},{-16,-13,

0},{-10,-13,-2},{-12,-13,-2},{-14,-13,-2},{-16,-13,-2},{-10,-13,-4},{-\
12,-13,-4},{-14,-13,-4},{-16,-13,-4},{-10,-13,-6},{-12,-13,-6},{-14,-13,-6},
{-\
16,-13,-6},{-10,-13,-8},{-12,-13,-8}};

    Show[Graphics3D[
      {   (* these brakets are essential*)
        RGBColor[1,0,0],PointSize[0.04],
        For[i=1;pts={},i< Length[position],i++,
          pts=AppendTo[pts,Point[ position[[i]] ]]];
        pts
        }, (* these brakets are essential*)
        Axes->True
      ]];

But, far better is the following.

    Show[Graphics3D[
        {
          RGBColor[1,0,0],PointSize[0.04],
          Map[Point,position]
          }, Axes->True
        ]]

And we can avoid thinking very much by using the function ScatterPlot3D from
the standard package Graphics`Graphics`

Load the package:

    <<Graphics`Graphics3D`

Now plot:

ScatterPlot3D[position, PlotStyle\[Rule]{RGBColor[1,0,0],PointSize[0.04]}];

Allan
---------------
Allan Hayes
hay at haystack.demon.co.uk
Voice: +44 (0)116 241 8747
Fax: +44 (0)870 164 0565






position={{-10,-13,0},{-12,-13,0},{-14,-13,0},{-16,-13,0},{-10,-13,-2},{-12,
-13,-2},{-14,-13,-2},{-16,-13,-2},{-10,-13,-4},{-12,-13,-4},{-14,-13,-4},{-1
6,-13,-4},{-10,-13,-6},{-12,-13,-6},{-14,-13,-6},{-16,-13,-6},{-10,-13,-8},{
-12,-13,-8}};
Show[Graphics3D[
{
RGBColor[1,0,0],PointSize[0.04],
For[i=1;pts={},i< Length[position],i++,pts=AppendTo[pts,Point[
position[[i]] ]]];
pts
}, Axes->True
]];
Show[Graphics3D[
{
RGBColor[1,0,0],PointSize[0.04],
Map[Point,position]
}, Axes->True
]]
<<Graphics`Graphics3D`
ScatterPlot3D[position, PlotStyle®{RGBColor[1,0,0],PointSize[0.04]}];


  • Prev by Date: Re: Integration of BesselJ[1,z] and BesselJ[0,z]
  • Next by Date: Re: not linear homogeneus differential equation system... too complicated for mathmeatica... maybe only for me! :)
  • Previous by thread: RE: For[] command in Show[] function
  • Next by thread: Integration of BesselJ[1,z] and BesselJ[0,z]