1
$\begingroup$

I need to calculate the distance between two spheres. The outcome of equation should be value determinating speed of moving object (Trying to implement II Kepler's Law). I managed to do something like this, but it doesn't seem to work. I know the equations that I am using are correct because I've checked the simulation in Unity.

enter image description here

$\endgroup$
1
  • $\begingroup$ You're calculating the distance of mesh points. The Position node is a field (=position of the mesh points). I don't know how the distance of 2 field inputs is calculated. But the positions of the sphere objects are stored in Object Info->Location. Isn't that what you want? $\endgroup$
    – Blunder
    Commented Apr 21, 2022 at 18:49

2 Answers 2

1
$\begingroup$

For a symmetric object like a sphere, by definition, the geometric center is also the center of the object's bounding box. One way to find that center using Geometry Nodes is to add the bounding box minimum and maximum together and divide by two. Once you have the two centers, you can use the Distance math function to determine how far apart they are. Here's an example with two generated spheres:

Calculating the distance between two spheres in Geometry Nodes.

You can visualize this by using the distance result as one end point of a mesh line:

Mesh line visualization of the length

Here I've set the line to grow on the Z axis as the spheres move apart. If I join the two spheres to the geometry, you can adjust the position of either sphere using its transform node and watch the line grow and shrink as the spheres move farther apart or closer together.

$\endgroup$
0
$\begingroup$

So what you need for Kepler's law is the distance between the centers of two spheres. I have a little bit goofy but working solution: Ditance between two spheres

Basically you scale each sphere to zero, join two of them to one geometry, calculate the bounding box and the distance between the min and max of your bounding box is the distance you're looking for.

$\endgroup$

You must log in to answer this question.

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