# [metapost] [NTG-context] MetaPost transformation

Dan Luecking luecking at uark.edu
Thu May 31 04:37:51 CEST 2012

At 07:56 PM 5/30/2012, Troy Henderson wrote:
>Well then in case anyone needs such a transformation, I've
>constructed the (non-unique) transformation T
>
> > t:=angle(f,e);
> > q:=e++f;
> > p:=(c*f-d*e)/q;
> > s:=(c*e+d*f)/(q**2);
> > transform T;
> > T:=identity rotated t xscaled p yscaled q slanted s shifted (a,b);
>
>This yields T=(a,b,c,d,e,f).

You can implement something like what you wanted directly
because, just as you can write equations for the parts of
a pair, you can also write equations for the parts of a
transform:
vardef mktransform (expr a,b,c,d,e,f) =
save T_; transform T_;
xpart  T_ = a;
ypart  T_ = b;
xxpart T_ = c;
xypart T_ = d;
yxpart T_ = e;
yypart T_ = f;
T_
enddef;

After this
transform T;
T := mktransform (1,2,3,4,5,6);
show T;
produces:
>> (1,2,3,4,5,6)

Regards,
Dan

Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html

More information about the metapost mailing list