epix-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ePiX-users] 3D datafile plotting


From: Andrew D. Hwang
Subject: Re: [ePiX-users] 3D datafile plotting
Date: Sat, 29 Nov 2008 09:10:48 -0500 (EST)

On Sat, 29 Nov 2008, Constantin Greubel wrote:

> Is it also possible to plot surfaces instead of scattered points? E.g. like
> the pole.xp sample, but points given through a datafile instead of a function.
>
Offhand I don't have an elegant solution, but something like this should
work:

---(snip)---
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

unsigned int N(20); // 20 x 20 mesh
std::vector<double> mydat; // will store data here

// returns points whose height comes from data
P g(unsigned int i, unsigned int j)
{
  if ((N+1)*i + j < mydat.size())
    return P(i, j, mydat.at((N+1)*i + j));

  else
    return P(i, j, 0); // should never hit this case
}

// adapter, for flexibility
P f(double u, double v)
{
  return g(floor(N*u), floor(N*v));
}

domain R(P(0,0), P(1,1), mesh(N,N)); // [0,1] x [0,1]

int main()
{
  picture(...)

  begin();
  fill();
  data_file df(...);    // generate or read data
  mydat = df.column(1); // extract column into pre-declared vector

  surface(f, R);        // and plot

  pst_format();
  end();
}
---(snip)---

Best,
Andy

Andrew D. Hwang                 address@hidden
Department of Math and CS       http://mathcs.holycross.edu/~ahwang
College of the Holy Cross       (508) 793-2458 (Office: Swords 339)
Worcester, MA, 01610-2395       (508) 793-3530 (fax)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]