groff
[Top][All Lists]
Advanced

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

RE: [Groff] couple of questions regarding pic


From: Ted Harding
Subject: RE: [Groff] couple of questions regarding pic
Date: Fri, 18 Aug 2000 13:21:59 +0100 (BST)

On 17-Aug-00 Wolfgang Huber wrote:
> 
> 1) is it possible to rotate an object?
> for example "box rotated 45 degrees"?
> (i know i could input an eps-file but I would prefer a pic-solution)

As things stand, unfortunately not. It would be very useful, especially
since box, circle and ellipse are the only pic objects that can be
filled, but they are restricted to being aligned with the axes of
the page.

If you just want the outline of the box (i.e. its four edges) you can
always write a pic macro to do it, but you won't be able to fill it
(since it will emerge simply as four lines). E.g.

.PS
define rbox {
w = $1
h = $2
t = $3
cx = Here.x
cy = Here.y

blx = cx + 0.5*h*sin(t)
bly = cy - 0.5*h*cos(t)
brx = blx + w*cos(t)
bry = bly + w*sin(t)
ulx = blx - h*sin(t)
uly = bly + h*cos(t)
urx = ulx + w*cos(t)
ury = uly + w*sin(t)

line from (blx,bly) to (brx,bry) to (urx,ury) to (ulx,uly) to (blx,bly)

}

pi = 4*atan2(1,1)
move to (3,3)
box wid 1 ht 1
move to (3,3)
rbox(1,1,pi/10)

.PE


> 2)plotting of functions
> there are examples both in the Kernighan manual and the manual by Eric
> S Raymond but they are with centered types. 
> I made my own version but it just generates nonsense:
> .PS
> pi = atan2(0,1)
> for i = 0 to 2 * pi by 0.1 do {
> "-" at i/2 , 0
> }
> move left 2 * pi
> for i = 0 to 2 * pi by 0.1 do {
> line to i/2 , sin(i)/2
> }
> .PE
> 
> What is wrong?

It works (or at any rate does something not altogether silly, though
I think it needs tidying up) if you get pi as

pi = 4*atan(1,1)

instead of

pi = atan2(0,1)

(you should have used 2*atan2(0,1) anyway), since for some reason
this returns the result 0:

sprintf("%6.4f",pi) -> 0.0000

Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 284 7749
Date: 18-Aug-00                                       Time: 13:21:59
------------------------------ XFMail ------------------------------

reply via email to

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