(Not in university, for a personal project)
I have a special equation for mapping from a cube to a sphere. It's particularly good for minimizing the distortion near the corners (attached).
However, I also need the inverse mapping. In other words, I need to solve the system of equations for x, y, z (position on a cube) given x', y', z' (position on a sphere). I've heard you're supposed to take 2 equations at a time and eliminate a variable, but I don't know how to do that with these square roots. Any help would be greatly appreciated.
Equation from: https://catlikecoding.com/unity/tutorials/cube-sphere/
#Mapping Sphere to Cube
29 messages · Page 1 of 1 (latest)
- Wait patiently for a helper to come along.
- Once someone helps you, say thank you and close the thread with:
+close
- Feel free to nominate the person for helper of the week in #helper-nominations
- Do not ping the mods, unless someone is breaking the rules.
- If you're happy with the help you got here, and the server overall, you can contribute financially as well:
Cool! The inverse might not be expressible in elementary functions, though.
Oy vey. I mean I can approximate the solution by computing a look-up-table but... I'd really rather not do that if computing the exact solution is possible and isn't too complex computationally
Hmm... Perhaps it would be easier if we switched to spherical coordinates? Not sure, though.
It might be simpler if I try to solve for just the top of the cube, so z = 1
Oh, that's true!
At least for that I get:
x' = x * sqrt(0.5 - y^2/2 + y^2/3)
y' = y * sqrt(0.5 - x^2^2 + x^2/3)
z' = sqrt(1 - x^2/2 - y^2/2 + x^2*y^2/3)
maybe this helps?
1 = x'^2 + y'^2 + z'^2
But I keep getting in the situation where I can't figure out how to further eliminate a variable
Then we have:
X = x√(1/2 - y^2/6)
Y = y√(1/2 - x^2/6)
Squaring and multiplying by 6 produces:
6X^2 = x^2 (3 - y^2)
6Y^2 = y^2 (3 - x^2)
Let's replace the equations by their sum and difference.
6(X^2 + Y^2) = 3x^2 - 2x^2 y^2 + 3y^2
2(X^2 - Y^2) = x^2 - y^2
From the second equation:
x^2 = 2(X^2 - Y^2) + y^2
Substituting into the first, we get:
6(X^2 + Y^2) = (3 - 2y^2)(2(X^2 - Y^2) + y^2) + 3y^2
And this is a quadratic equation in y^2, so the rest shouldn't be a problem.
I multiplied that out to:
0 = 6y^2 - 2y^4 - 12y'^2 - 4y^2x'^2 + 4y^2y'^2 but that doesn't seem like a quadratic 💀
When I try another way I get:
x'^2 = x^2 * (0.5 - 6y'^4 / (x^4 - 6x^2 + 9))
but fml that's got x^4
i aint going to an engineering college if this is the maths questions
i am NOT making it to college 😭 🙅🙅‼️
I've spent 5 hours on this, please kill me
whats even the question
Solve for x, y, & z
uh
i think
y+mx+c
x=my+c
z = idk
that's the best ik
im in middle school literally
Tried wolfram, holy crap is it really this complicated:
It is quadratic in y^2.
6(X^2 + Y^2) = (3 - 2y^2)(2(X^2 - Y^2) + y^2) + 3y^2
Let u^2 = X^2 + Y^2, v^2 = X^2 - Y^2. Then:
(2y^2 - 3)(y^2 + 2v^2) - 3y^2 + 6u^2 = 0
2y^4 + 2(2v^2 - 3)y^2 + 6(u^2 - v^2) = 0
y^4 + (2v^2 - 3)y^2 + 3(u^2 - v^2) = 0
So, now you can solve for y^2.
WHAT
+close