epix-users
[Top][All Lists]
Advanced

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

[ePiX-users] Re: ePiX-users Digest, Vol 13, Issue 7


From: Math Plot
Subject: [ePiX-users] Re: ePiX-users Digest, Vol 13, Issue 7
Date: Sun, 7 Oct 2007 13:34:20 +0200


Hi,

First, thanks for your help.

The program is generating vertical test tube with a semi circular base. An elliptical base would be nice.

How can be generate horizontal cylinder partially filled with liquid with an arrow indicating the height of the liquid?

We also need partially filled cone and shpere with liquid is emphasized with some colour.




On 9/28/07, address@hidden <address@hidden > wrote:
Send ePiX-users mailing list submissions to
         address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.nongnu.org/mailman/listinfo/epix-users
or, via email, send a message with subject or body 'help' to
        address@hidden

You can reach the person managing the list at
         address@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of ePiX-users digest..."


Today's Topics:

   1. Re: drawing cylinder with epix (Andrew D. Hwang)


----------------------------------------------------------------------

Message: 1
Date: Thu, 27 Sep 2007 21:56:07 -0400 (EDT)
From: "Andrew D. Hwang" < address@hidden>
Subject: Re: [ePiX-users] drawing cylinder with epix
To: ePiX User List <address@hidden >
Message-ID: <address@hidden>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

On Wed, 26 Sep 2007, Math Plot wrote:

> I am new to the epix. So, my question may be too naive for you.
>
Not at all, though the question belongs here on the user list, not on the
development list. :)

> We want to draw cylinder in two positions: horizontal and vertical. The
> top and bottom of cylinder may be circle or ellipse. We also want to
> emphasize the liquid level inside the cylinder with some color.
>
The approach to take depends on your needs. For example,

* Do you want to draw stylized test tubes (graduated cylinders, etc.)
or simply "bare" cylinders partly filled with fluid?

* Do you need true 3-D to draw tubes in various spatial orientations, or
can you use a partially shaded 2-D outline?


The simplest but least flexible approach is to make a quick sketch (with
pencil and paper), then to translate this into 2-D drawing commands. A
first attempt at test tubes is included below. (The results look all right
to me, but the code is neither pretty nor robust.)

It may be worth writing a "tube" class whose parameters (position, radius,
length, amount and color of fluid, etc.) are set by member functions. This
buys flexibility at the expense of effort and programing knowledge.

Hope that's helpful in getting started; feel free to ask if you have more
questions.

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

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

// Stylized test tube of given radius, height, and fluid level; bottom of
// tube is a semi-circle with given center. The "ratio" controls fake
// perspective.
void test_tube(const P& ctr, double rad, double ht,
               double level, double ratio=0.1)
{
   plain();
   fill();
   // draw (2-D) outline of liquid, for shading
   path liquid(ctr, P(rad,0), P(0,rad), -M_PI, 0); // bottom of tube
   liquid += path(ctr+P(rad,0), ctr+P(rad,level)); // side of tube

   // will cover this with an ellipse momentarily
   liquid += path(ctr+P(rad,level), ctr+P(-rad, level));

   liquid += path(ctr+P(-rad,level), ctr+P(-rad,0)); // other side
   liquid.close().fill().draw();

   ellipse(ctr+P(0,level), P(rad, 2*rad*ratio)); // top surface of liquid

   // re-draw tube outline
   nofill();
   bold();
   ellipse_bottom(ctr, P(rad, rad));
   line(ctr+P(rad,0), ctr+P(rad,ht));
   line(ctr+P(-rad,0), ctr+P(-rad,ht));
   ellipse(ctr+P(0,ht), P(rad, ratio*rad));

   // and lip at top
   bbold();
   ellipse(ctr+P(0,ht), P(rad+0.0125, ratio*rad));
}

int main()
{
   picture(P(-1,-3), P(1,3), "2x6in");

   begin();
   pst_format();

   fill(Red(1.8));
   test_tube(P(-0.75, -2.5), 0.25, 5, 3);

   fill(Blue(1.8));
   test_tube(P(0.5, -2.5), 0.5, 4, 1.5);

   end();
}


0

------------------------------

_______________________________________________
ePiX-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/epix-users


End of ePiX-users Digest, Vol 13, Issue 7
*****************************************


reply via email to

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