I'm trying to find a formula that could convert my 3D global coordinates into local object space.

Here are the inputs I have

A Location

B Location
B Rotation
B Scale 

I need a Location output, corresponding to my A Location in B Space, according to B Location, Rotation, and Scale. I'm working in a 3D Space

So far I didn't found any formulas online, anyone can point me in the right direction? Bests

If possible, i'd need a formula that doesn't use any matrix calculation, it's not supported by the nodal system of my engine (I'm using blender geometry node, but my problem is more generic as you can see)

  • \$\begingroup\$ What representation(s) can you use for B's rotation? Can you get it as a quaternion or angle-axis pair? Euler angles are a bit messy to invert. \$\endgroup\$
    – DMGregory
    Feb 2, 2021 at 16:12
  • \$\begingroup\$ Euler unfortunately ( in degrees) \$\endgroup\$
    – DB3D
    Feb 2, 2021 at 16:16

1 Answer 1


You'll have to unpeel the transformations applied to B one by one, in reverse order. Typically we'll apply transformations in the sequence...

  1. Scale
  2. Euler Roll
  3. Euler Pitch
  4. Euler Yaw
  5. Translate

So going backwards from 5 back to 1 (and assuming the {yaw, pitch, roll} axes are {z, x, y} - I'm not super familiar with Blender's conventions so you might need to swap some):

Untranslated = A.Location - B.Location

Unyawed = Yaw(Untranslated, -B.Rotation.z)

Unpitched = Pitch(Unyawed, -B.Rotation.x)

Unrolled = Roll(Unpitched, -B.Rotation.y)

Unscaled = Scale(Unrolled, (1/B.Scale.x, 1/B.Scale.y, 1/B.Scale.z) )

Now Unscaled is the point in B's local coordinate space that corresponds to the point A in the global coordinate space.

Here's how we can implement those rotation and scale functions:

(If your sine and cosine functions take their input in radians, be sure to convert your degree inputs to radians first)

Yaw(point, angle) {
    s = sin(angle)
    c = cos(angle)

    return (point.x * c - point.y * s, 
            point.y * c + point.x * s,

Pitch(point, angle) {
    s = sin(angle)
    c = cos(angle)

    return (point.x, 
            point.y * c - point.z * s, 
            point.z * c + point.y * s)

Roll(point, angle) {
    s = sin(angle)
    c = cos(angle)

    return (point.x * c + point.z * s,
            point.z * c - point.x * s)

Scale(point, scaleTriplet) {
    return (point.x * scaleTriplet.x,
            point.y * scaleTriplet.y,
            point.z * scaleTriplet.z)
  • \$\begingroup\$ Thanks for the answer, How does Rotate() and Scale() translate to mathematical calculation? \$\endgroup\$
    – DB3D
    Feb 2, 2021 at 16:49
  • \$\begingroup\$ You have access to a "transform point" node that takes Euler angle and scale triplet inputs, no? \$\endgroup\$
    – DMGregory
    Feb 2, 2021 at 16:52
  • \$\begingroup\$ Unfortunately no, i only have some vector math, or Float math nodes at my disposal, That's why I'm currently searching for a "raw" formula, with no matrix formulas \$\endgroup\$
    – DB3D
    Feb 2, 2021 at 16:53
  • \$\begingroup\$ I've added some potential implementations in pseudocode above. \$\endgroup\$
    – DMGregory
    Feb 2, 2021 at 17:04
  • \$\begingroup\$ Though I'll note, if you have access to vector math nodes like dot products, you can implement any matrix-based solutions you've found too. A matrix multiplication is just a set of dot products, taking the rows (or columns) of the matrix as vectors. \$\endgroup\$
    – DMGregory
    Feb 2, 2021 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .