#include "TRandom.h" #include "TCanvas.h" #include "TView.h" #include "TPolyMarker3D.h" void spheres(Int_t nspheres=20, Int_t npoints=100000) { // generate random points uniformly distributed over the surface // of spheres generated at random positions. TCanvas *c1 = new TCanvas("c1","spheres",600,600); c1->SetFillColor(kBlack); TView *view = new TView(1); Double_t k=0.8; view->SetRange( -k, -k, -k, k, k, k); //generate sphere coordinates and radius TRandom r; if (nspheres <=0) nspheres = 10; Double_t *xs = new Double_t[nspheres]; Double_t *ys = new Double_t[nspheres]; Double_t *zs = new Double_t[nspheres]; Double_t *rs = new Double_t[nspheres]; Int_t i; for (i=0;iSetMarkerColor(kRed); Double_t x,y,z; for (Int_t j=0;jSetPoint(j,xs[i]+x, ys[i]+y,zs[i]+z); } delete [] xs; delete [] ys; delete [] zs; delete [] rs; pm->Draw(); }