I'm trying to understand how to use two positions nodes relative to two different meshes. In the following example, I thought that the grid would be translated relative to the coordinates of the one vertex output by the mesh line node. But this is not happening. Am I missing something?
You have to read the geometry nodes from right (end) to left (beginning).
Your example doesn't make a lot of sense, because the positions of vertices in a Mesh Line are very predictable (linear interpolation between start and end), and so rather than sampling it, you can just mix RGB two vectors... So let's say we want to drag a cuboid across all vertices of an icosphere:
- Group Output has a Geometry Input, so that's where the execution goes.
- Set Position has a Geometry Input as well, so that's where the execution goes...
- Cube node generates a cuboid mesh, and the execution returns to Set Position.
- Set Position iterates over all vertices, for each vertex it needs to evaluate the Offset, and so it sets context to vertex #0 and goes left to TA.
- Transfer Attribute has geometry attached...
- Icosphere nodes generates an icosphere mesh, and the execution returns to TA.
- Transfer Attribute now evaluates Index, so it goes left through two math nodes to the statistics...
- Round goes to Multiply ⬅
- Multiply goes to statistics ⬅
- Attribute Statistic has geometry attached...
- As in 6. Probably the geometry is cached and not generated each time, but it doesn't matter, as each time it would be generated in the same way (it's deterministic). The flow returns to statistics.
- Attribute Statistic samples the input (the index) for each vertex of attached icosahedron, by going left through the Attribute input.
- Index node gives an icosahedron vertex index, because the context changed to the icosahedron.
- Attribute Statistic goes to the next icosahedron vertex, and repeats p.13 Eventually it reaches the last icosahedron vertex and sends forward the largest of the samples (
41) to the Multiply node. The context returns to the cuboid vertex.
- Math > Multiply still needs another term, so execution goes left to evaluate it.
- Multiply Add needs a value.
- Separate XYZ needs to read the Vector attached.
- Position node yields the location of currently evaluated context - the cuboid vertex.
- Separate XYZ ➡
- Multiply Add ➡
- Multiply ➡
- Round ➡
- Transfer Attribute finally can do the work. It evaluated the index, so now it knows which icosphere's vertex to access. This ico-vertex now becomes the context, as Attribute input is evaluated.
- Position of the current context = icosphere's vertex is passed forward ➡
- Transfer Attribute changes the context back to the cuboid's vertex, but passes forward the position of icosphere's vertex ➡
- Set Position offsets current context = cuboid vertex, by icosphere's vertex position. Then it changes the context to the next cuboid's vertex, and goes back to p. 4. Eventually all cuboid vertices are evaluated, and the changed geometry is passed forward ➡
- Group Output gets back the requested geometry. The end.
As the manual entry for Position Node makes perfectly unclear:
The Position node outputs a vector of each point of the geometry the node is connected to.
That is, the position node only provides information on the object that the GeometryNodes modifier is attached to. They're not relative to the two meshes you've created.
You can't use the position node to access data about meshes you create within the node tree.
If by "two different meshes" you mean two meshes you created within the node tree, as in your example, just use their geometry data directly. If you mean meshes that are externally created, then use an Object Info node to get the data from the others.
If you want to translate the mesh using an input, something like this would do it:
Replace the Vector input node by whatever nodes you need to generate the translation you want.