'Calculate a point's position relative to the parent's transform

I'm trying to make my own Transform system similar to Unity's but it's in a 2D space

I get everything (positions, rotations, scale) works except, for localPosition - Which tells the local position of an object relative to it's parent's transform.

In Unity, this can be done by calling Transform.InverseTransformPoint function but since it's code is hidden and that I'm making it in 2D space, I can't figure it out



Solution 1:[1]

you need to use matrix transformation for hierarchies transform. here is some information about this:

https://paroj.github.io/gltut/Positioning/Tut06%20Fun%20with%20Matrices.html

https://www.youtube.com/watch?v=HgQzOmnBGCo

https://www.youtube.com/watch?v=IrggOvOSZr4

https://www.youtube.com/watch?v=09I15RO49vg

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mahdi Po