3D Relative Transformations

SomeCoderSomeCoder Posts: 1Member
edited February 11 in Programming

Hello All,

I am relativity new to 3D transformations and believe that this is something I need to learn more of. However in my current situation I have a case which I am struggling with, to convey I have attached a (poorly drawn) image. Please note while the drawing is in 2D the actual case is 3D.

I have the parent node P, and 2 children nodes A and B. The node A already has a transformation to get it into the position I want. I want to calculate a position relative to A (using its own relative coordinate system) to move it forward 2 units in the x direction. I then want to get the transformation of this position B relative to the parent P.

Right now my best guess of how to proceed would be to ?somehow? calculate the vector of A>B and then use the knowledge of P>A to figure out P>B. Although I am stumped at how to find this local transformation. I am also not sure if this is the right path to go down and would greatly appreciate if someone could point in me in the right direction so I can go away and learn how to finish up on this task.

Thanks very much all.

Answers

  • wombatstampedewombatstampede Posts: 72Member

    I put up some kind of tutorial which deal with 3D Transforms. Perhaps it is helpful:
    https://godotdevelopers.org/forum/discussion/18480/godot-3d-vector-physics-cheat-sheet

    It also deals with the difference between local and global transforms.

    To your problem:
    As I understood A is a child of P.
    So its transform is local to P.

    If you want to move A inside the parents transform (= as a child) in its x-direction I'd say that this is the code:

    NodeA.transform.origin += NodeA.transform.basis.x * distance
    

    This'll change the local position of Node A in direction of its local transform x-Vector by distance units.

    Example: Be P be a moving and turning ferry. Be A some person on that ferry.

    The person now wants to move 2m left (x-axis). Then their local position should change by NodeA.transform.basis.x * 2.

Sign In or Register to comment.