HI there,

[cosm.field] basically gives you efficient interpolated lookup of 2D and 3D matrices by another matrix of positions. Typical uses would be visualizing fields with particle systems.

The third inlet should be a matrix which represents the 'field' to be sampled; it should be 2D or 3D. It can have any number of planes.

The first inlet specifies spatial coordinates (e.g. agent positions) with which to sample the field. If the field is 2D, the coordinates should be 2-plane (XY); if the field is 3D they should be 3-plane (XYZ). The coordinates range from 0..1, which is mapped to the dimensions of the field matrix. The results of this sampling come out of the first outlet of [cosm.field]. The dimensions of this output will match the dimensions of the first inlet, but the plane-count will match the plane-count of the field itself. That is, if the field has 4 planes, and the sampling positions is a 1D matrix of 32 elements, the result will be a 1D, 4-plane matrix. The nth cell in this matrix contains the four field voxel values for the nth coordinate position that was sent in.

The sampling uses bilinear interpolation (2D fields) or trilinear interpolation (3D fields). That means a sampling point that is somewhere between two pixels/voxels will return a weighted average of them.

It's important to make sure that the field matrix is sent to [cosm.field] before the sampling positions are sent, and also to remember that the sampling positions are in the 0..1 range (not the scale of the field matrix or of the world). You probably need to scale the agent positions first.

For those cases where you want to do interpolated lookup of a matrix for just a single position, consider using [cosm.field.query] instead.

Hope that helps!

Graham