Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Question about Random Animation
QtWS25 Last Chance

Question about Random Animation

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kale Lou
    wrote on last edited by
    #1

    Hi everyone,

    I am trying to make a small software of mobile network performance simulation. For the display part, I wanna to have several vehicle icons move randomly in screen. Currently, my idea is based on the Animation Framework Examples, such as "Animated Tiles" and "Move Blocks". Basically, they use "QState" to predefine a set of geometry states and randomly pick one of them when the program run.

    My question is how to make the geometry state random, so that you will see the car image randomly move in the screen, not just a set of patterns.

    Anyone has any idea or any example code?

    Thanks in advance.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      This kind of depends on how many degrees of freedom you have. If there's two (e.g (x, y)) you can relatively easily parameterize it based on a random number. If there's three, you might want to be using more inputs.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • B Offline
        B Offline
        brandont
        wrote on last edited by
        #3

        Just another small point. The random integers should be 1 or -1 (multiply an integer for different speeds). Just add the number to the coordinates. Unless of course you want the cars to teleport around the screen. :P

        You might not want your cars to turn on every step, so you might choose a prng that "tends" to stay constant. Maybe something like this:
        @
        a is the generated number
        b is a private double
        Increase b by a small random amount under 1 (say under 0.3).
        If b is not over 1
        return last a
        if b is =< 1
        return random a
        @

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          Teleporting is a basic feature of cars, right?

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            Franzk: This might be a research project on teleporting cars, you never know. It is amazing where Qt is used nowadays:-)

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved