diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-09-21 20:54:51 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2018-09-21 20:54:51 +0200 |
commit | 7c2efd42267783f01b64e0a47cba89f84742618c (patch) | |
tree | 4517e6bd3e024424dd82c5bb3c5e800cdff06fea /metapost/context/base/mpiv/mp-tres.mpiv | |
parent | 56ca0139232f16679918613ef45a5dd643f0f9b3 (diff) | |
download | context-7c2efd42267783f01b64e0a47cba89f84742618c.tar.gz |
2018-09-21 20:00:00
Diffstat (limited to 'metapost/context/base/mpiv/mp-tres.mpiv')
-rw-r--r-- | metapost/context/base/mpiv/mp-tres.mpiv | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/metapost/context/base/mpiv/mp-tres.mpiv b/metapost/context/base/mpiv/mp-tres.mpiv index 335670a98..c331d71af 100644 --- a/metapost/context/base/mpiv/mp-tres.mpiv +++ b/metapost/context/base/mpiv/mp-tres.mpiv @@ -96,14 +96,14 @@ primarydef p XYZscaled q = (q*Xpart p,q*Ypart p,q*Zpart p) enddef ; -vardef projection expr t = - if triplet t : +vardef projection primary t = + (if triplet t : (Xpart t, Ypart t) transformed Txy shifted (0,Zpart t) - elseif pair t : + elseif pair t : t transformed Txy - else : + else : origin transformed Txy - fi + fi) enddef ; %D This overloads the plain macro \type {abs} (being \type {length}): @@ -166,6 +166,59 @@ vardef draw_vector@# (expr v, s) text t = fi enddef ; +%D Transform a (2D) path to a 3D plane + +def XYpath primary p = + (for i=0 upto (length p) if cycle p: -1 fi : + if i>0 : .. fi + projection (xpart point i of p, + ypart point i of p, + 0) + ..controls + projection (xpart postcontrol i of p, + ypart postcontrol i of p, + 0) + and + projection (xpart precontrol (i+1) of p, + ypart precontrol (i+1) of p, + 0) + endfor if cycle p: ..cycle fi) +enddef ; + +def XZpath primary p = + (for i=0 upto (length p) if cycle p: -1 fi : + if i>0 : .. fi + projection (xpart point i of p, + 0, + ypart point i of p) + ..controls + projection (xpart postcontrol i of p, + 0, + ypart postcontrol i of p) + and + projection (xpart precontrol (i+1) of p, + 0, + ypart precontrol (i+1) of p) + endfor if cycle p: ..cycle fi) +enddef ; + +def YZpath primary p = + (for i=0 upto (length p) if cycle p: -1 fi : + if i>0 : .. fi + projection (0, + xpart point i of p, + ypart point i of p) + ..controls + projection (0, + xpart postcontrol i of p, + ypart postcontrol i of p) + and + projection (0, + xpart precontrol (i+1) of p, + ypart precontrol (i+1) of p) + endfor if cycle p: ..cycle fi) +enddef ; + %D Some constants... triplet Origin, Xunitvector, Yunitvector, Zunitvector ; |