summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv')
-rw-r--r--Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv105
1 files changed, 44 insertions, 61 deletions
diff --git a/Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv b/Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv
index 617855473c2..0cc209302ea 100644
--- a/Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv
+++ b/Master/texmf-dist/metapost/context/base/mpiv/mp-base.mpiv
@@ -201,7 +201,7 @@ let graycolor = numeric ;
% color part (will be overloaded)
def colorpart primary t =
- if colormodel t = 7:
+ if colormodel t=7:
(cyanpart t, magentapart t, yellowpart t, blackpart t)
elseif colormodel t = 5 :
(redpart t, greenpart t, bluepart t)
@@ -250,7 +250,7 @@ vardef whatever =
?
enddef ;
-% unary operators (with patched round)
+% unary operators
let abs = length ;
@@ -258,14 +258,7 @@ vardef round primary u =
if numeric u :
floor(u+.5)
elseif pair u :
- (floor(xpart u+.5), floor(ypart u+.5))
- elseif path u :
- % added by HH
- for i=0 upto length u-1 :
- round(point i of u) ..
- controls round(postcontrol i of u) and round(precontrol i+1 of u) ..
- endfor
- if cycle u : cycle else : point infinity of u fi
+ (round xpart u, round ypart u)
else :
u
fi
@@ -330,65 +323,22 @@ primarydef w dotprod z =
(xpart w * xpart z + ypart w * ypart z)
enddef ;
-% primarydef x**y =
-% if y = 2 :
-% x*x
-% else :
-% takepower y of x
-% fi
-% enddef ;
-%
-% def takepower expr y of x =
-% if x>0 :
-% mexp(y*mlog x)
-% elseif (x=0) and (y>0) :
-% 0
-% else :
-% 1
-% if y = floor y :
-% if y >= 0 :
-% for n=1 upto y :
-% *x
-% endfor
-% else :
-% for n=-1 downto y :
-% /x
-% endfor
-% fi
-% else :
-% hide(errmessage "Undefined power: " & decimal x & "**" & decimal y)
-% fi
-% fi
-% enddef ;
-
-% for big number systems:
-
primarydef x**y =
- if y = 0 :
- 1
- elseif x = 0 :
- 0
- elseif y < 0 :
- 1/(x**-y)
- elseif y = 1 :
- x
- elseif y = 2 :
+ if y = 2 :
x*x
- elseif y = 3 :
- x*x*x
else :
takepower y of x
fi
enddef ;
def takepower expr y of x =
- if y=0 : % isn't x**0 = 1 even if x=0 ?
- 1
- elseif x=0 :
+ if x>0 :
+ mexp(y*mlog x)
+ elseif (x=0) and (y>0) :
0
else :
+ 1
if y = floor y :
- 1
if y >= 0 :
for n=1 upto y :
*x
@@ -398,14 +348,47 @@ def takepower expr y of x =
/x
endfor
fi
- elseif x>0 :
- mexp(y*mlog x)
else :
- -mexp(y*mlog -x)
+ hide(errmessage "Undefined power: " & decimal x & "**" & decimal y)
fi
fi
enddef ;
+% for big number systems:
+%
+% primarydef x**y =
+% if y = 1 :
+% x
+% elseif y = 2 :
+% x*x
+% elseif y = 3 :
+% x*x*x
+% else :
+% takepower y of x
+% fi
+% enddef ;
+%
+% vardef takepower expr y of x =
+% if (x=0) and (y>0) :
+% 0
+% else :
+% 1
+% if y = floor y :
+% if y >= 0 :
+% for n=1 upto y :
+% *x
+% endfor
+% else :
+% for n=-1 downto y :
+% /x
+% endfor
+% fi
+% else :
+% hide(errmessage "Undefined power: " & decimal x & "**" & decimal y)
+% fi
+% fi
+% enddef ;
+
vardef direction expr t of p =
postcontrol t of p - precontrol t of p
enddef ;