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

Re: Plotting TODO



Thus spake Aaron Lehmann:
> 
> 
> On Fri, 11 Feb 2000, Nils Barth wrote:
> 
> > Thus spake Aaron Lehmann:
> > > I looked at this dir, some plots look pretty hard. However, if you can
> > > compute vector fields, I can draw them into a drawing area fairly easily
> > > :).
> > 
> > hehe -- well, you wanted a challenge, eh?
> > re: vector fields.
> > computing them is trivial:
> > given two functions (the x-component and the y-component):
> > (f(x,y),g(x,y)), just evaluate f and g at a bunch of points.
> > For example, if f(x,y)=sin(x), g(x,y)=cos(x*y), to plot the vector
> > field, just choose a bunch of points
> > (say, (0,0), (1,0), (2,0), ... (5,0), (0,1), ... (5,1), ... (0,2)
> > .. (5,2), ... (5,5))
> > and then at the point (x,y), put the vector (f(x,y),g(x,y))
> > 
> > Is this what you're looking for w/r/t `computing vector fields'?
> 
> I think I understand. But a vector has a magnitude component and a
> direction component, how do i find the direction?

Oh!
magnitude/direction is just another way of specifying (x,y)
Recall that any point in the plane can be considered as either a
cartesian pair (x,y) or in polar coordinates as (r,theta)
with conversion being:
r=sqrt(x^2+y^2)
theta=arctan(y/x) (well, if x>0 -- otherwise add pi) (and have a
special case for x=0 -- then theta = pi/2 if y>0, and -pi/2 if y<0)
(and if x=y=0, then just set theta=0)

or:
x=r*cos(theta)
y=r*sin(theta)

``magnitude and direction'' just means think of the vector field in
polar coordinates. It should be easier to plot if the vector field is
given in cartesian coordinates.

Does this answer your question?

> > The other concerns with plotting vector fields are the assorted
> > scaling options (this is easy to add in later -- for instance, you
> > might ask to scale all vectors by a factor of 1/2 so they don't crash
> > into each other or something), and rotated arrowheads (which is a bit
> > harder, but should be easy with any library that offers affine
> > transforms -- what's the GNOME replacement for Imlib?)
> 
> Sounds important. GdkPixbuf is catching on as an Imlib replacement, but
> implementing a vector field as a canvas item and using libart for affine
> transforms seems like the most sensible idea for now.

Right -- that's what I was trying to say, but you know this stuff much
better.

-- 
  -nils