Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

NetPlot3D[]

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: NetPlot3D[]
  • From: rar at mail.physics.utah.edu (rudolph a romer)
  • Date: Mon, 14 Sep 1992 15:51:48 -0600

mathgroup:

    The following piece of MMA code may help solve a recently posted
problem with ListPlot3D[]:

    Since ListPlot3D[] only accepts a list of height values in
    standard matrix format (that is the data points are assumed to lie
    on a regular rectangular grid), a general list of data points of
    the form {{x1,y1,z2},{x2,y2,z2},...} can not be displayed via
    ListPlot3D[].

    I ran into this problem sometime ago while working on random
triangulations for the shape-from-shading problem. The following
MMA-package still assumes that the (x,y)-pairs lie on a lattice, but
the lattice points may very in their elementary cell dimensions.

    I hope that posting this package might help in developing a more
general solution to this problem.

    -Rudo

###########################################################################
# Rudolf A. Roemer (RAR)         Room:   306 James Fletcher Building      #
# Department of Physics          Email:  rar at mail.physics.utah.edu        #
# University of Utah                     roemer at dec1.physik.fu-berlin.de  #
# Salt Lake City, Utah 84112     FAX:    USA (801) 581 4801               #
# USA                            Phone:  USA (801) 581 6424               #
#                                        USA (801) 596 1527 (home)        #
###########################################################################

-----Cut here -----
(*****************************************************************
 *
 *  N E T
 *
 *  A Mathematica program for displaying nets
 *
 *****************************************************************)
 
(*****************************************************************
 *
 * File: Net.m
 *
 * 260591 RAR: NetPlot3D[] can handle lists of different xy sizes
 * 030591 RAR: installation
 *  
 *****************************************************************)

(*****************************************************************
 *
 * Setting up the context
 *
 *****************************************************************)
        
BeginPackage[
  "Net`",
  "FilterOptions`"
]


(*****************************************************************
 *
 * Usage messages
 *
 *****************************************************************)

Net::usage =
  "Net.m is an extension of the usual ListPlot functions for arrays
that do not follow the usual grid format." 

NetPlot::usage =
  "NetPlot[{{x1,y1},{x2,y2} ..}, opts] plots a net with vertices at the given
coordinates."
  
NetPlot3D::usage =
  "NetPlot3D[{{x1,y1,z1},{x2,y2,z2} ..}, opts] plots a net with vertices
at the given coordinates in 3D. The x and y coordinates are optional." 
    
(*****************************************************************
 *
 * Setting up the `private` context
 *
 *****************************************************************)
 
Begin["`private`"]

NetPlot[coords_List, opts___Rule]:=
  Show[
    Graphics[
      Join[
        Map[ Line, Transpose[coords] ],
        Map[ Line, coords ]
      ]
    ],
    AspectRatio->Automatic,
    FilterOptions[Graphics, opts]
  ]

NetPlot3D[l3:{{{_, _, _}..}..}, opts___Rule]:=
  Show[
    Graphics3D[
      Table[
        Polygon[
          { l3[[i]][[j]],
            l3[[i+1]][[j]],
            l3[[i]][[j+1]],
            l3[[i+1]][[j+1]]
          }
        ],
        {i,Length[l3]-1}, {j, Length[l3[[i]]]-1}
      ]
    ],
    FilterOptions[Graphics, opts],
    BoxRatios->{1,1,.4}
  ]
   
NetPlot3D[l1:{{_..}..}, opts___Rule]:=
  Block[{i,j},
    NetPlot3D[
      Table[
        {i, j, l1[[i]][[j]]},
        {i, Length[ l1 ]},
        {j, Length[ l1[[i]] ]}
      ],
      opts
    ]
  ]
  
(*****************************************************************
 *
 * End the `private` context
 *
 *****************************************************************)
 
End[ ]


(*****************************************************************
 *
 * Protect exported symbols
 *
 *****************************************************************)

Protect[
  NetPlot, NetPlot3D
];

  
(*****************************************************************
 *
 * End the package
 *
 *****************************************************************)

EndPackage[ ]
                  
           
         
    







  • Prev by Date: Re: Can MMa run on a NeXT with 8Mbyte?
  • Next by Date: NoFillHistogram Package
  • Previous by thread: Re: Using ListPlot3D with real x,y.z coordinates
  • Next by thread: NoFillHistogram Package