nexusformat / definitions

Definitions of the NeXus Standard File Structure and Contents
https://manual.nexusformat.org/
Other
26 stars 56 forks source link

[QUESTIONs] re: NXtransformations #1226

Closed padraic-shafer closed 1 year ago

padraic-shafer commented 1 year ago

Newbie here, learning the NeXus coordinate system. With coordinate transforms there is often a sign convention to define: Am I rotating the coordinate values or the coordinate basis? I have a few questions to help clarify my understanding.

  1. It appears that the approach of the NXtransformations is to adjust the coordinate frame of the enclosing nx:group, relative to some other coordinate frame (either a previous upstream component or the default coordinate system). Is that correct so far?
  2. Is the @offset value moving the origin of the new coordinate frame, relative to the origin of the previous coordinate system? [I.e. (x', y', z') in the new coordinates the same point in absolute space as (x, y, z) - (x, y, z)_offset in units of the previous coordinate system.
  3. According to NXtransformations the @depends_on attribute points from "inner" transformation operations toward the next "outer" operation. That is, the @depends_on chain moves from the object being transformed toward the object after transformation. More compactly, T = T3 * T2 * T1 is the same as T1 depends_on T2 depends_on T3 depends_on .. ... Under this scheme, how does one indicate the starting reference frame from an earlier component? [This would require @depends_on to point in the opposite direction.]
  4. Could I have separate NXtransformations for NXsample and NXsample/magnetic_field that each refer to a common upstream coordinate frame (i.e., that of the incoming beam)?
padraic-shafer commented 1 year ago

And is there a way to refer to the enclosing group of the enclosing group, something like filesystem ../ in the @depends_on attribute's value?

mkoennecke commented 1 year ago

1) Is correct 2) The offset is with regard to the previous coordinate system 3) Is correct. The end of the transformations chain is marked with a . in depends_on. Ideally you should be at the origin of the coordinate system then. 4) That is possible. NXtransformations group are independent but of course can reference each other.

And yes, you can use a ../.. notation for relative links in depends_on attributes

padraic-shafer commented 1 year ago

Thank you for these concise and helpful answers.

According to NXtransformations the @depends_on attribute points from "inner" transformation operations toward the next "outer" operation. That is, the @depends_on chain moves from the object being transformed toward the object after transformation. More compactly, T = T3 * T2 * T1 is the same as T1 depends_on T2 depends_on T3 depends_on .. ... Under this scheme, how does one indicate the starting reference frame from an earlier component? [This would require @depends_on to point in the opposite direction.]

Of course this works as intended! I had it backward in my mind--mistakenly thinking that the transformations relative to earlier upstream components needed to be applied first. But in fact, they come last--after the "local" transformations. E.g. The rotations of a sample goniometer (T1, T2, T3) get applied to the sample first...then the displacement of the sample stage relative to the previous optic (T4, T5, T6) could be applied. This maintains the documented order of the @depends_on chain, and also gives the correct result for the sample orientation w.r.t the previous reference frame.