Jens-Uwe Morawski | 10 Nov 2003 14:01
Picon

Re: Line in rectangle

On Fri, 07 Nov 2003 18:06:50 +0100
Maurizio Vianello <mvs52 <at> lombardiacom.it> wrote:

> Dear Fellow MP users:
> 
> I have defined  a path which is simply a rectangle, let's call it "border".
> 
> I want to define a macro which, given as inputs the coordinates of two 
> points inside the rectangle,  would draw a line through the two points up 
> to the border, and not further.

path border ; border := unitsquare xscaled 5cm yscaled 3cm ;

def Macro(expr a, e)=
  draw (border intersectionpoint
    ((a+(infinity*unitvector(a-e)))--a))--
  (border intersectionpoint
    (e--(e+(infinity*unitvector(e-a))))) ;
enddef;

beginfig(1);
  draw border ;
  Macro ((1.1cm,2.5cm),(2cm,1cm)) ;
  Macro ((2cm,2.5cm),(1cm,2cm)) ;
  Macro ((1mm,2.5cm),(4cm,3mm)) ;
endfig;

end.

> Moreover, I have a simple question: Is there any way one could redifine the 
> basic unit of MP so that, for instance (2,3) means (2cm,3cm), without using 
> a construction like unit*(2,3). I mean: is ther a way to tell MP from  the 
> beginning that I want my basic unit to be cm (for instance).

no, afaik

Best,
  Jens

Gmane