[Gridflow-dev] common patterns and protocols

Mathieu Bouchard matju at sympatico.ca
Mon Jan 17 23:23:48 EST 2005

Hi, here's some (new) documentation on common patterns of usage in
GridFlow, and/or glossary. Please give me feedback on whether you like it
and whether it is insightful. For some reason, almost all that came up to
my mind is very math-related...

I don't quite know yet how much math should go in the manual and what
should be specifically left out.

Field: any set of numbers and +,-,*,/ operators that sufficiently work
like the usual ones. The most common examples are Rationals (Q), Reals (R)
and Complexes (C). Because those fields are infinitely vast, the ints and
floats are just approximations of fields, in various ways. The ints have
their +,-,* that wrap around upon overflow, and their / is rounding. The
floats don't have wrap-around but their +,-,*,/ are all rounding, albeit
to very small increments (not even a millionth of the exact result).
Because of their division operators, ints are very bad approximations of
fields, while floats are much better.

Scalar (grid): a Dim[] Grid (0-dimensional indices). Also, any single
element of a Vector, Matrix, Grid, ...

Scalar (math): a component of a Vector. (strict rules of vector math
require the set of Scalars to be a Field)

Vector (grid): a Dim[n] Grid (1-dimensional indices). Also, any innermost
Dim[n] subgrid; e.g. in a Dim[240,320,3] picture, every pixel is a Dim[3]
"Vector" and is innermost because 3 is the last dimension.

Vector (math): any linear combination made from the basis elements of a
vector space. This can be applied to most anything as long as you can add
things together and multiply by a constant. The other definition of grid
is a special case of it (if you pretend that its Scalars are in a true

Point: synonym for Vector, when using spatial metaphors. (supposing that
the origin and axes have been decided...)

Vector Space: the set of all possible linear combinations of a set of

Linear Combination: a sum of products by constants.

Convex Combination: a sum of products by constants such that the constants
add up to 1. For example, (x*50+y*25+z*25)/100 mixes 50% of x with 25% of
y and 25% of z. This is cross-fading with any number of inputs.

Dimension: any freely-varying value. This can apply to cells in a grid
just like it can apply to positions in a grid. Do not confuse the two! For
example, a RGB pixel may be a Dim[3], so it is a three-dimensional vector
because three values may vary, but it is a "one-dimensional" grid because
all the cells are "in the same row". A triangle may be a Dim[3,2], so it
is a six-dimensional vector (though laid out as a matrix), but it is a
"two-dimensional" grid because there's a "vertex axis" (3 vertices) and a
"spatial axis" (x and y position of each vertex).

Metric: a function with two inlets and one outlet such that it finds "the"
distance between the two. There are many different valid distance
concepts. For example, a distance function could account for obstacles in
trying to get from one point to another, and another could ignore them.
The distance may be a metaphor, for example, the distance between two
colors (color_detect.pd does it that way) suggests a space for which each
point is a color.

Norm: a function with one inlet and one outlet such that it finds the
distance between two things when given their difference. Combining [@ -]
with a Norm gives a translation-independent Metric.

Euclidean Norm (aka "Pythagorean Norm"): is the only possible
rotation-independent Norm; so it's very commonly used. It corresponds to
our intuitive concept of straight-line distance. It's just a [@! sq]
followed by a [@fold + 0] followed by a [@! sqrt]. The last step is very
slow and can be omitted, if compensated for (e.g. color_detect.pd).

Scalar Product: an extension of the concept of Norm. It has two inlets and
one outlet. The Dot Product is the usual version of it. [#inner] can do
the job of a Dot Product. In geometric terms, a dot product gives you the
length of a vector times the length of another vector times the cosine of
the angle between the two. This can be useful to find the degree of
"relatedness" between two directions, where 0 means perpendicular, and
positive means acute angle.

Matrix Product: can be seen as a bunch of Scalar products between two sets
of points. used in geometry, it represents a change of axes.


(add your stuff here)

Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju

More information about the Gridflow-dev mailing list