<p>Typically the time portion of the computation is based on a clock. There are several ways to get a good time step in nanoseconds from the OS. Delta t is just the current time stamp minus the last time stamp, where the time stamp is usually taken at the beginning of each frame. This tells us the amount of time that has elapsed since the last frame. That data is used to compute how far the planet has moved during delta t.</p>
<p>Use delta t combined with the system movement data, such as the velocity of the planet to compute the position of the object. It sounds like the planet may move through several velocity regions during a single delta t, so that complicates things a bit but overall should give an accurate animation of the movement.</p>
<p>The nice thing about this set up is the more accurate the velocity data is, the more accurate the animation will be. Also, the external clock can be arbitrarily changed to slow down or speed up the animation.</p>

CC BY-SA 4.0
2024-12-16T12:52:04.903Z
2024-12-16T12:52:04.903Z
pmw1234
<p>I am building a solar system application where a planet rotates around a star.</p>
<p>SHORT INTRO: To store the orbit points I have a simple vector std::vector where Point3D is a simple struct containing 3 double values for x, y, z coords. This vector contains 10'000 values of 3D points in space which define an elipse around a sun. I also have std::vector to contain speeds at every single point, so another vector of 10'000 values. Generated elipse (a vector of 10'000 values) is densily populated closer to the sun than it is further from the sun <a href="https://i.sstatic.net/1KNjysH3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1KNjysH3.png" alt="enter image description here" /></a> which in itself (from mathematical or scientific point of view) correct. I have checked on how to generate orbital points and orbital speeds. Objects that move towards the central body (i.e. in this case a planet moving towards sun) are increasing it's speed, and objects that move away from the central body decrease in speed.</p>
<p>PROBLEM: The problem I am facing is that to render this I am using a simple FOR loop that iterates all the 10'000 points. Since every iteration (from the computational part) takes the same amount of time it makes it look like when the planet is closer to the sun it moves way slower than when it is futrther away. This is a code that I use to render the application:</p>
<pre><code>void SolarSystemVTKInteractor::Step()
{
    const std::unordered_map&lt;int, StellarSystem::Planet&gt;&amp; planetMap = m_solarSystemModel.GetPlanetsMap();
    // Check needed to ensure that during planet addition or deletion there was enough time to create planet object and planet sphere
    if (m_planetSpheresMap.size() != planetMap.size())
    {
        return;
    }
    static const std::unordered_map&lt;int, double&gt;&amp; planetsRotationDegrees = m_solarSystemModel.GetPlanetsRotationDegrees();
    for (auto&amp; [id, planet] : planetMap)
    {
        int stepIterator = planetMap.at(id).GetStepIterator();
        Physics::Point3D nextOrbitalPoint = planet.GetOrbitalPoints().at(stepIterator);
        m_planetSpheresMap.at(id).MoveActor(
            nextOrbitalPoint.x / StellarSystem::DISTANCE_MULTIPLIER,
            nextOrbitalPoint.y / StellarSystem::DISTANCE_MULTIPLIER,
            nextOrbitalPoint.z / StellarSystem::DISTANCE_MULTIPLIER
        );
        m_planetSpheresMap.at(id).RotateActor(planetsRotationDegrees.at(id));
        m_solarSystemModel.Step();
    }
}
</code></pre>
<p>How can I fix the rendering part so that I could visually see that the objects moving towards the sun are increasing it's speed and those that are moving away from it are decreasing in speed?</p>
<p>Any kind of answer is appreciated.</p>

<rendering><3d><c++><vtk><gui>
How to render speed change using VTK (or any other renderer)?
artas2357
# How to render speed change using VTK (or any other renderer)?

(Asked by: username_0 on 2024-12-16)

I am building a solar system application where a planet rotates around a star.

SHORT INTRO: To store the orbit points I have a simple vector std::vector where Point3D is a simple struct containing 3 double values for x, y, z coords. This vector contains 10'000 values of 3D points in space which define an elipse around a sun. I also have std::vector to contain speeds at every single point, so another vector of 10'000 values. Generated elipse (a vector of 10'000 values) is densily populated closer to the sun than it is further from the sun [![enter image description here](https://i.sstatic.net/1KNjysH3.png)](https://i.sstatic.net/1KNjysH3.png) which in itself (from mathematical or scientific point of view) correct. I have checked on how to generate orbital points and orbital speeds. Objects that move towards the central body (i.e. in this case a planet moving towards sun) are increasing it's speed, and objects that move away from the central body decrease in speed.

PROBLEM: The problem I am facing is that to render this I am using a simple FOR loop that iterates all the 10'000 points. Since every iteration (from the computational part) takes the same amount of time it makes it look like when the planet is closer to the sun it moves way slower than when it is futrther away. This is a code that I use to render the application:

```
void SolarSystemVTKInteractor::Step()
{
    const std::unordered_map<int, StellarSystem::Planet>& planetMap = m_solarSystemModel.GetPlanetsMap();
    // Check needed to ensure that during planet addition or deletion there was enough time to create planet object and planet sphere
    if (m_planetSpheresMap.size() != planetMap.size())
    {
        return;
    }
    static const std::unordered_map<int, double>& planetsRotationDegrees = m_solarSystemModel.GetPlanetsRotationDegrees();
    for (auto& [id, planet] : planetMap)
    {
        int stepIterator = planetMap.at(id).GetStepIterator();
        Physics::Point3D nextOrbitalPoint = planet.GetOrbitalPoints().at(stepIterator);
        m_planetSpheresMap.at(id).MoveActor(
            nextOrbitalPoint.x / StellarSystem::DISTANCE_MULTIPLIER,
            nextOrbitalPoint.y / StellarSystem::DISTANCE_MULTIPLIER,
            nextOrbitalPoint.z / StellarSystem::DISTANCE_MULTIPLIER
        );
        m_planetSpheresMap.at(id).RotateActor(planetsRotationDegrees.at(id));
        m_solarSystemModel.Step();
    }
}

```

How can I fix the rendering part so that I could visually see that the objects moving towards the sun are increasing it's speed and those that are moving away from it are decreasing in speed?

Any kind of answer is appreciated.

**Tags:** rendering, 3d, c++, vtk, gui


---

## 1 answers

### Answer by username_1 on 2024-12-16. Score: 1

Typically the time portion of the computation is based on a clock. There are several ways to get a good time step in nanoseconds from the OS. Delta t is just the current time stamp minus the last time stamp, where the time stamp is usually taken at the beginning of each frame. This tells us the amount of time that has elapsed since the last frame. That data is used to compute how far the planet has moved during delta t.

Use delta t combined with the system movement data, such as the velocity of the planet to compute the position of the object. It sounds like the planet may move through several velocity regions during a single delta t, so that complicates things a bit but overall should give an accurate animation of the movement.

The nice thing about this set up is the more accurate the velocity data is, the more accurate the animation will be. Also, the external clock can be arbitrarily changed to slow down or speed up the animation.


---

