Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Metafont
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Variables and equations=== Variables in Metafont can be of eight different types: * Numeric: [[fixed-point arithmetic|fixed-point]] signed numbers with an [[machine epsilon|epsilon]] of <math>2^{-16}</math>, capped to be less than 4096 ([[Q (number format)|Q12.16]]). This is the default for variables not declared to be of another type. * Pair: a pair of numerics, used primarily for representing points in the plane. * Path: as in [[PostScript]]/[[PDF]]/[[Scalable Vector Graphics|SVG]], a [[parametric curve]] in the plane whose coordinate functions are [[piecewise]] cubic polynomials. As in those other systems, path segments are encoded as [[Bézier curve]]s in terms of knots and control points. * Transform: an [[affine transformation]] of the plane, equivalent to a "(transformation) matrix" in PostScript/PDF. * Pen: a convex polygon, representing the shape of a "pen" used for drawing. * Picture: a [[raster graphics|raster image]] with a signed integer value for each pixel. * [[Boolean data type|Boolean]] * String (of 8-bit characters) [[Metapost]] adds color (a triple of numerics) as a ninth type and has a completely different (non-raster) model for pictures; the latter is the main point of divergence between the two programs. Metafont vardef macros also live in the same namespace as variables and may in some ways be regarded as a ninth type of variable, although macros do not exist as [[first-class citizen|first-class]] values in Metafont. Unusually, the names of variables are not simple tokens, but sequences of symbolic tokens and numeric indices; the variable name <code>x2r</code> is thus not one [[alphanumeric]] token, but a sequence of the three tokens <code>x</code> (symbolic), <code>2</code> (numeric), and <code>r</code> (symbolic). [[Record (computer science)|Record]] and [[Array data type|array]] types may be simulated through collections of variables that share a common name prefix, an idiom supported by the type declaration system giving all variables whose names which differ only in numeric indices the same type (as expected for arrays) while keeping variables whole name differ in some symbolic token separate (as expected for records). A very distinctive feature of Metafont is the use of [[equation]]s to define variables. A numeric variable (or component of a pair or transformation variable) may be in the three states ''known'' (set), ''unknown independent'' (not set), and ''unknown dependent'' (not set, but given by a [[Linear function (calculus)|linear expression]] of one or several independents). When Metafont executes an equation statement, it turns one of the independents involved into a dependent and eliminates it from the expressions for all other dependents; when no independents remain in the expression for a dependent variable, that variable becomes known. Solving [[system of linear equations|''linear'' equation systems]] thus is a built-in feature of the Metafont language, and the recommended method of assigning most variables (especially those whose values have geometric significance) is to state equations determining their values. Equation systems frequently mix numeric (scalar) equations with pair (vector) equations. An exception to the above is the class of ''internal quantity'' variables. These have names consisting of just one symbolic token, are always numeric, and are always known. They have a more direct internal representation than ordinary variables, making it convenient for primitive operations in Metafont (or extensions thereof) to use them implicitly.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Metafont
(section)
Add topic