Grasshopper 3D's Z-up system to vvvv gamma's Y-up system

Coming here after reading the whole 20 years´ forum history of Coordinate System transformations!

What am I doing wrong?
The rotations still do not match!

Grasshopper:
Exporting a csv with these columns ( I need to do it via csv)
tx, ty, tz (mm),
rx, ry, rz (degrees),
sx, sy, sz(mm)

VVVV conversions:
240521_LS_01.vl (96.1 KB)

var tx = ExtractedTx/1000
var ty = ExtractedTz/1000 // Swap Y and Z
var tz = ExtractedTy/1000 // Swap Y and Z
var rx = ExtractedRx/360
var ry = -ExtractedRz/360 // Swap and negate Rz for Y-up system
var rz = ExtractedRy/360 // Swap Ry with Rz
var sx = ExtractedSx/1000
var sy = ExtractedSz/1000
var sz = ExtractedSy/1000

Thanks in advance

You should make a test object, like arrow, a size of 1 unit, then you need to create same object by hand in vvvv, then you can start aligning.

Normally i would start with just importing a geo as is (only degrees converted) and apply to that a root transform (the one that rotates object against 0,0,0 point). Basically if you fix scene transform, you can then apply same logic to values you build or just directly multiply.

The point is, it’s easier to assemble transform directly then apply axis conversion (scale, rotate, transform)

Also note you forgot to upload csv.

I think @tonfilm can answer this probably, as we had to do this conversion many times, but I seem to remember that it is easier to do with Quaternions (for the rotation) or Matrixes.

Here is a cool chart by the incredible Freya Holmér:

Rhino is top right, vvvv is top left.

sidenote: thought it was hilarious that Tim Sweeney actually apologized for basically using a coordinate system for Unreal, that nobody else uses

1 Like

there is this node that might be handy: CoordinateSystemConversion [3D.Transform]

3 Likes

Not to forget this (free) course by @motzi:

4 Likes

@antokhio
Attached a clean version with all the referenced files
I have compared the rhino file (with the Rhino reader) with the imported csv.
Made some negative switches to the imported csv data but still not able to visualize it correctly. I have chatgpted who s suggesting quaternions but not clear to me and apparently to it as well since it did not give me proper instructions.
@bjoern thank s for the lead, it would be definitely great to learn it properly, need some time. If someone knows a shortcut,
@ joreg I have tried CoordinateSystemConversion [3D.Transform] with no luck, everything was completely messed up a help file would be gold for me.
testVVVVImportRhinoCSV.zip (96.8 KB)

I think rhino is Z up and left handed, so bottom left. vvvv is Y up and right handed, so upper right.

Generally, it depends on what you want to import. But the VL.Rhino3dm Library already solves that, are you using the that?

Wouldn’t that mean X would go to the left? In Rhino it looks like that:

image

If Z is up, Y is back and X is to the right, it would be right-handed, Z is up, so bottom right.

As you can tell, even after working with this stuff for so long, its still confusing… :D

jeez, the bottom right is what I meant. Unreal is alone there on the bottom left. :)
and yes, that means it is also right-handed.

1 Like

thanks @bjoern for mentioning the course, but unfortunately i did not cover the “converting rotations” issues there. orientations/rotations can be really a super confusing topic as one has to be aware in detail what the data represents and how to convert it to the desired system (i’ve been several times at the point where i thought that i know what i’m doing, just to find out that my mental model does not work as expected).

however - as @seltzdesign already mentioned, from my experience it is mostly easiest to convert to quaternions, do a transformation there (usually flipping and negating one or more components) and then convert back to the desired format (or leave it as quaternion).

unfortunately i’m quite busy right now so i cannot look into your patch atm :(

i just had a few minutes on the train and had a quick look:

  • your data is stored in SRT form (a vector for each scale, rotate and translate)
  • translation can be simply handled by exchanging and negating compontents to convert the axis
  • rotation is stored as an “Euler rotation sequence”. this is the format that is loathed by anyone dealing with rotations in 3D for a number of reasons (quaternions are usually preferred).
    • important: these are actually 3 rotations (around 3 individual axis) performed in a certain sequence. if you don’t know which sequence/hierarchy this is, you will not succeed in converting them. in VVVV we have the sequence ZXY (by default), other programs might do this differently or even allow you to set the sequence (in VVVV this can be done by performing 3 different rotations in a row, where only one axis is rotated.

if you can find out what sequence we have here, we might be able to convert it. whithout that info it’s just guessing…

2 Likes

ps: this video explains quite well what the problem with certain euler rotation hierarchies is:

also: in this patch from my workshop the euler rotation hierarchy is patched out.

TransformSRT_Scale_Rotate_Translate.vl (73.3 KB)

sorry, still no solution to your problem but maybe some insight…

1 Like

I remember doing a lot of transfers of transformation data the other way, from vvvv to Grasshopper many years ago. I might be able to dig out a patch, but I seem to remember that I actually wrote transformation matrixes into the .csv in the end, because they are easier to convert. Pretty sure you had to flip the matrixes and then swap a few things around. I’ll see if I can find it.

Yes, found it.

This is the patch in Grasshopper. I am importing transform matrixes coming from a CSV written in vvvv.

This helped me as well to understand the different formats of the matrixes.

Here is the vvvv part. Its still in vvvv beta since its from 2017, but you will get the gist. Important is the Transpose part to transpose the matrixes to the other format, then write the values. In GH you read the values and swap the values around.

Forum_Answers_vvvv.zip (34.4 KB)

ps: if you want to go from GH/Rhino to vvvv, I would recommend writing a rhino file and then using GitHub - wolfmoritzcramer/VL.Rhino.3dm: VL Library to access Rhino *.3dm Files to import into vvvv, just as tonfilm mentioned.

Coincidentally, there is a class by the plugin author about Rhino + vvvv tomorrow: SS24 – VVVV – Integrating Rhino 3D with VVVV – The NODE Institute

3 Likes

Rhino to Unreal SRT via csv data structures working perfectly by negating x and y translations

Rhino handles rotations in the order XYZ

But what is confusing me is that, inside of vvvv, it means XZY? Since we are talking about a rhino coordinate system with Z up and vvvv with Y up? So first I should swap Y and X from the incoming data and then applying that order? I will give another attempt.

Already used VL.Rhino.3DM for some time and it works wonderfully doing the transformation job for you,+ filtering, taggging etc.

But unfortunately it looks not dealing properly with the rhino blocks (called InstanceReference), as you may want to check from the file attached. The matrix coming out from the Split node seems reading only the translation. Please correct me if I am doing anything wrong.

My job requires exactly translating thousands of block instance transformations, so this nuget looks useless for the purpose.

And thanks for this the workshop
240522_VLRhino3dm_Blocks_noScaleRotation.zip (587.2 KB)

Not sure if it helps, but I found this on my disk:


        public static Matrix XFormToMatrix(ref Transform t)
        {
            return new Matrix(
                    (float)t.M00, (float)t.M20, (float)t.M10, (float)t.M30,
                    -(float)t.M02, -(float)t.M22, -(float)t.M12, -(float)t.M32,
                    (float)t.M01, (float)t.M21, (float)t.M11, (float)t.M31,
                    (float)t.M03, (float)t.M23, (float)t.M13, (float)t.M33
                );
        }

so with some swapping and negating, you can convert the rhino matrix to a vvvv matrix. but I am not sure in what form the matrix from the Rhino lib comes and what processing has to be done. maybe you can access the original XFrom from Rhino somewhere.

Just sorted this out with the right sorting/negation
240521_VVVVImportRhinoCSV_Solved.zip (101.1 KB)

  • Swap the incoming Y and Z

  • Negate the new Z (that was Y before) for both translation and rotation,

  • Apply rotations in order ZXY (that´s how vvvv sorts them, thanks @motzi ) receiving data from XYZ (that´s how rhino sorts them)

Thanks everyone, seriously! Attached patch

2 Likes

Idk if @wmc is frequenting the forum so maybe make an issue on github?

2 Likes