2
$\begingroup$

I want to measure velocity and acceleration of an object in real time using geometry nodes. As you can see the box is moving (animation keyframe is used travelling 15meter in 150 frames (24fps setting)) and a text above is there (i want to show velocity and acceleration there ). How to this. I know simulation nodes is the answer but i can't able to figure out the logic and nodes to use it. I want to measure velocity and acceleration considering in 3D space

enter image description here

$\endgroup$
5
  • $\begingroup$ ok, silly question: "As you can see the box is moving" -> how shall we see that!? $\endgroup$
    – Chris
    Commented Mar 20 at 7:08
  • 2
    $\begingroup$ next question: how did you add the velocity and acceleration to your object? via animation? via python? via GN? via animation nodes? our answer depends on that. So pls just add an example blend file, so we don't have to ask in comments. thx. $\endgroup$
    – Chris
    Commented Mar 20 at 7:10
  • $\begingroup$ animation keyframe is used travelling 15 meter in 150 frames (24fps setting) $\endgroup$ Commented Mar 20 at 7:43
  • 1
    $\begingroup$ 'Real Time' ? Do you mean interactively in the viewport,? Or as animated.. (motion stored in keyframes) $\endgroup$
    – Robin Betts
    Commented Mar 20 at 10:40
  • $\begingroup$ Interactively in the viewport . Assume this that i have a box moving 15m distance (travel in 150 frame) at 10m/s (24fps) Now i want to show velocity and acceleration of the box in the viewport in place of text as shown in image. If i am missing any input please tell me. $\endgroup$ Commented Mar 20 at 12:49

1 Answer 1

3
$\begingroup$

I'm not sure if your problem is to determine the data like velocity and acceleration or how to display them via Geometry Nodes.

Anyway, I would do it like this: first of all you need an object with a Geometry Nodes modifier. In the nodetree you reference the object which you want to measure with an Object Info node (set to Relative), plugged into a Simulation Zone.

To make sure the calculations are based on the object's starting position, you need to store the initial Location as named attribute. In the simulation, you can simply compute the different values by their formulas:

$$v=\frac{\Delta s}{\Delta t}=\frac{s_2-s_1}{t_2-t_1}$$

Velocity $v$ is equal to the difference between current location and previous location divided by the difference in time, comfortably enough the Simulation Zone has a Delta Time output.

For the acceleration $a$ you have the following formula:

$$a=\frac{\Delta v}{\Delta t}=\frac{v_2-v_1}{t_2-t_1}$$

Again, Delta Time is provided by the Simulation Zone, and the current velocity minus the previous velocity needs to be calculated.

Additionally, I thought I could measure the travelled distance by simply adding the distances between each frame together (because a simple difference between start and end position will only work for a linear movement).

I stored the values for velocity, acceleration and distance in a single vector attribute as values X, Y and Z. Then I stored the new location as attribute to have a previous location for the next step.

Nodetree for the Simulation Zone and data storage:

simulation nodes

The next part is just getting the data into strings to display them as text. One problem is, that I cannot plug the values from the attribute directly into a Value to String node, because it only takes single values but the attributes have a field output. Therefore I need a Sample Index node. I set it to vector to get all values from the attribute and then split them with a Separate XYZ node.

The next is just getting everything into string form, then convert it to a curve with String to Curves nodes, then I also added description and units and placed everything with Set Position nodes, combined everything etc. I had to use multiple nodes because I wanted to align descriptions, values and units separately from each other.

The nodetree for the text:

nodetree strings

And now the result, the cube moves from (0, 0, 0) to (0, 15, 0) like in your example. I don't know how you have keyframed it, I've set the Interpolation to Bézier because Linear would have been a bit boring... otherwise apart from the beginning, the acceleration would stay 0 all the time and also the velocity would be 2.4 m/s constantly (you said 10 m/s in your question, but 0.1 m per frame with 24 FPS is 2.4 m/s). So here you can see the velocity increasing and decreasing and therefore the acceleration change from positive to negative:

velocity result

The good thing is, since you said something about "interactively", any object can be referenced in the Object Info node, even objects without keyframes. In the following animation I select a sphere while the animation is running and press G to move it around: the values will show as well. Of course this only works with a running animation, otherwise the Simulation Zone is not working and has no time reference.

interactive measuring

Because this is a bit complex, here is the file for download:

$\endgroup$

You must log in to answer this question.

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