i want to multiply by 0 part of the velocity vector, that points from center of sphere1 to center of sphere2. So easiest way i can think of is to calculate velocity vector in new coordinate system where R1 vector is y or x, multuply y or x by 0 and than go back to global coordinates. But only way i can imagine it in current geonodes is to calculate angle btwn local and global X and than rotate the whole vector, manipulate it and then rotate it back. But it gets really hard when we go from 2 dimensions to 3 dimensions. Any ideas pls?
-
1$\begingroup$ I'm not sure if I fully understand what you're talking about, but you could probably use a dot product to see if a vector is pointing in that direction and scale it accordingly. $\endgroup$– shmuelCommented Sep 19, 2023 at 15:37
-
$\begingroup$ i need to change specific part of the velocity vector so it does not point in the direction of another shpere. postimg.cc/jwZnTkn2 here is the image so, we have global X and Y, two points (black), velocity vector (light blue), C1 and C2 vectors (C1 points to another point, it is first part of velocity vector, C2 is second part of velocity vector). So i want to scale C1 of velocity vector by 0, and get V2 vector (orange one) $\endgroup$– Кирилл АлексеевскийCommented Sep 19, 2023 at 15:54
-
$\begingroup$ This is probably a en.wikipedia.org/wiki/XY_problem and what you really need is Vector Math: Reflect. $\endgroup$– Markus von BroadyCommented Sep 19, 2023 at 15:57
2 Answers
Let me first try to Steelman your question:
This setup generates two balls and two arrows on the 2nd ball (called 'Sphere 2').
One, white arrow is just an arbitrary (random in this case) direction vector. The other, red arrow is the result of the operation you want.
I think the best way to explain what you want is: position a plane exactly between the two spheres, tangent to those spheres, then add a Sun aligned with the plane's normal (the Sun direction same as the direction from Sphere 2 to Sphere 1), and look at the shadow of the arrow - that's the direction the resulting vector should have:
(the red arrow is so dark because it's entirely in the shadow of the white arrow)
And so the question is, what should be the contents of the Meat custom group in the green frame, to achieve this:
Solution
Your solution works for 3D as well: rotate to be $z$-up, remove $z$ component, rotate back. It's just that you need Euler $xyz$ rotation rather than just a single angle. Here in order to ensure both balls touch, I position the 2nd ball by rotating the $<2, 0, 0>$ offset by a random Euler, so that Euler is ready to be used; normally you would start with a vector and need to calculate the Euler. The opposite of Vector Rotate node is Align Euler to Vector:
(same result as in Nathan's solution)
Vector Math: Reflect
i want to multiply by 0 part of the velocity vector, that points from center of sphere1 to center of sphere2.
The dot product of two normalized vectors is the projection of one vector onto the other (https://en.wikipedia.org/wiki/Dot_product#/media/File:Dot_Product.svg)-- the "shadow" cast from one vector onto the other, if you'd like.
Let's call the vector from one circle to the other circle the "proximity vector". If we take the dot product of the normalized velocity and proximity vectors, and multiply that by the length of the velocity vector, we get the size of that shadow cast by one vector on the other. If we then scale the normalized proximity vector by this "shadow size", we have the component of the velocity vector that lies along proximity vector; we can subtract it from the velocity vector to end up with a vector that points only orthogonally to the proximity vector. *
But only way i can imagine it in current geonodes is to calculate angle btwn local and global X and than rotate the whole vector, manipulate it and then rotate it back. But it gets really hard when we go from 2 dimensions to 3 dimensions.
This is a more complicated problem than I think you want to solve, and solving it probably (depending on how you look at what you're solving) involves calculating what you want to calculate, via the method I described above.
* Note: The way that I described this involves some unnecessary operations, but I'm presenting it as I am because I think it's a better way to ease into the thinking. The length of the shadow is dot(normalize(proximity), velocity), but knowing that requires knowing more about the dot product than I've explained and it can wait.