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. Path length instead of degrees.
Forum Updated to NodeBB v4.3 + New Features

Path length instead of degrees.

Scheduled Pinned Locked Moved Unsolved General and Desktop
24 Posts 5 Posters 4.0k Views 2 Watching
  • 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.
  • L Offline
    L Offline
    Loc888
    wrote on last edited by
    #1

    Hi, i am using QGraphicsScene, and there i wanna rotate one object, nearly another one. The static object is a circle, the moving object should move around the path.

    This is good, i can already simply rotate it. The problem is, i don't want to rotate it, i want to move it around that circle, but by the path length, so if the circle has 4000 length of any kind of units, so if i move it by 1000 units, it should do the angle of 90.
    (4000 / 1000 = 4 ---- 360 / 4 = 90)

    I dont want the angles, i want the path size, how could i achieve it? I have no idea how to do it, i just started with QGraphicsScene.

    JKSHJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      but what is "the path" ?

      1 Reply Last reply
      1
      • L Offline
        L Offline
        Loc888
        wrote on last edited by
        #3

        Road, way, lengh, distance value.

        mrjjM 1 Reply Last reply
        0
        • L Loc888

          Road, way, lengh, distance value.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Loc888
          Ok, im not really sure what you mean.
          Do you have an image of it ?

          1 Reply Last reply
          1
          • L Offline
            L Offline
            Loc888
            wrote on last edited by Loc888
            #5

            @mrjj
            Image? All i want, is instead of using 360 degrees, use a distance value.
            So if the circle has 120 cm of length, if i move another item on this circle by 60cm, it should do a 180 degree move.

            aha_1980A 1 Reply Last reply
            0
            • L Loc888

              @mrjj
              Image? All i want, is instead of using 360 degrees, use a distance value.
              So if the circle has 120 cm of length, if i move another item on this circle by 60cm, it should do a 180 degree move.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Loc888

              Then why don't you just calculate it? This is very simple math, you already gave an example yourself.

              L 1 Reply Last reply
              1
              • aha_1980A aha_1980

                @Loc888

                Then why don't you just calculate it? This is very simple math, you already gave an example yourself.

                L Offline
                L Offline
                Loc888
                wrote on last edited by
                #7

                @aha_1980 If i am posting it, i have the reason. In short reply, because of the accuracy, i will move that object by very small values. There are few more things, but doing it in this way make it useless.

                aha_1980A 1 Reply Last reply
                0
                • L Loc888

                  @aha_1980 If i am posting it, i have the reason. In short reply, because of the accuracy, i will move that object by very small values. There are few more things, but doing it in this way make it useless.

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8
                  This post is deleted!
                  L 1 Reply Last reply
                  0
                  • aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Loc888 Angle and circumference have a fixed ratio. Why should one be more or less precise than the other one?

                    1 Reply Last reply
                    0
                    • aha_1980A aha_1980

                      This post is deleted!

                      L Offline
                      L Offline
                      Loc888
                      wrote on last edited by
                      #10

                      @aha_1980 If you don't know how to do it, that's it, i will not talk about anything else, i know what i wanna achieve.

                      1 Reply Last reply
                      -1
                      • aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @Loc888

                        Right, I don't know how to do it, because you didn't supply a picture of your task.

                        But guess what: I don't care. And I won't talk anymore, too.

                        Regards

                        L 1 Reply Last reply
                        2
                        • aha_1980A aha_1980

                          @Loc888

                          Right, I don't know how to do it, because you didn't supply a picture of your task.

                          But guess what: I don't care. And I won't talk anymore, too.

                          Regards

                          L Offline
                          L Offline
                          Loc888
                          wrote on last edited by
                          #12

                          @aha_1980 How can i take a picture of units of length? If you can explain it.

                          1 Reply Last reply
                          0
                          • J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by J.Hilk
                            #13

                            a shot in the dark here, because I'm not entierly sure what you want to do, but this (it's untested)
                            should give you a point(x,y) depending on the radius and the length of the partial circumference.

                            its untested, and I think you'll need to adjust it to the correct point of origin

                            QPoint lengthToPoint(const int radius, const int semiCyrcleLength) {
                                //arc angle
                                double angle = (semiCyrcleLength *360)/(2* 3.1415 * radius);
                                //angle to x & y
                                QPoint p(cos(angle),sin(angle));
                                return  p;
                            }
                            

                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            1 Reply Last reply
                            4
                            • L Loc888

                              Hi, i am using QGraphicsScene, and there i wanna rotate one object, nearly another one. The static object is a circle, the moving object should move around the path.

                              This is good, i can already simply rotate it. The problem is, i don't want to rotate it, i want to move it around that circle, but by the path length, so if the circle has 4000 length of any kind of units, so if i move it by 1000 units, it should do the angle of 90.
                              (4000 / 1000 = 4 ---- 360 / 4 = 90)

                              I dont want the angles, i want the path size, how could i achieve it? I have no idea how to do it, i just started with QGraphicsScene.

                              JKSHJ Offline
                              JKSHJ Offline
                              JKSH
                              Moderators
                              wrote on last edited by JKSH
                              #14

                              @Loc888 said in Path length instead of degrees.:

                              if the circle has 4000 length of any kind of units, so if i move it by 1000 units, it should do the angle of 90.
                              (4000 / 1000 = 4 ---- 360 / 4 = 90)

                              ...

                              So if the circle has 120 cm of length, if i move another item on this circle by 60cm, it should do a 180 degree move.

                              double findDegrees(double fullCircleLength, double pathLength) {
                                  double ratio = fullCircleLength / pathLength;
                                  double angle = 360 / ratio;
                              
                                  return angle;
                              }
                              
                              int main() {
                                  qDebug() << findDegrees(4000, 1000); // Output: 90
                                  qDebug() << findDegrees(120, 60);    // Output: 180
                              
                                  return 0;
                              }
                              

                              Is this what you want?

                              @mrjj
                              Image? All i want, is instead of using 360 degrees, use a distance value.

                              Look, your words were not clear.

                              @mrjj asked you for an image so that he can understand what you want, so that he can help you. If you don't want to give him the image, then he cannot help you.

                              @aha_1980 If you don't know how to do it, that's it, i will not talk about anything else, i know what i wanna achieve.

                              @aha_1980 was also trying to help you. There is no need to be rude.

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              L 1 Reply Last reply
                              5
                              • JKSHJ JKSH

                                @Loc888 said in Path length instead of degrees.:

                                if the circle has 4000 length of any kind of units, so if i move it by 1000 units, it should do the angle of 90.
                                (4000 / 1000 = 4 ---- 360 / 4 = 90)

                                ...

                                So if the circle has 120 cm of length, if i move another item on this circle by 60cm, it should do a 180 degree move.

                                double findDegrees(double fullCircleLength, double pathLength) {
                                    double ratio = fullCircleLength / pathLength;
                                    double angle = 360 / ratio;
                                
                                    return angle;
                                }
                                
                                int main() {
                                    qDebug() << findDegrees(4000, 1000); // Output: 90
                                    qDebug() << findDegrees(120, 60);    // Output: 180
                                
                                    return 0;
                                }
                                

                                Is this what you want?

                                @mrjj
                                Image? All i want, is instead of using 360 degrees, use a distance value.

                                Look, your words were not clear.

                                @mrjj asked you for an image so that he can understand what you want, so that he can help you. If you don't want to give him the image, then he cannot help you.

                                @aha_1980 If you don't know how to do it, that's it, i will not talk about anything else, i know what i wanna achieve.

                                @aha_1980 was also trying to help you. There is no need to be rude.

                                L Offline
                                L Offline
                                Loc888
                                wrote on last edited by Loc888
                                #15

                                @JKSH I am not trying to be rude, i just wanted to say, i am not interested in doing this, by another way.
                                I am not sure if i am explaining it bad, but if you can't understand it, or maybe you are not sure, then i will make a simple image of it, maybe it will help.

                                JKSHJ 1 Reply Last reply
                                0
                                • L Loc888

                                  @JKSH I am not trying to be rude, i just wanted to say, i am not interested in doing this, by another way.
                                  I am not sure if i am explaining it bad, but if you can't understand it, or maybe you are not sure, then i will make a simple image of it, maybe it will help.

                                  JKSHJ Offline
                                  JKSHJ Offline
                                  JKSH
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  @Loc888 said in Path length instead of degrees.:

                                  @JKSH I am not trying to be rude, i just wanted to say, i am not interested in doing this, by another way.

                                  OK.

                                  I am not sure if i am explaining it bad, but if you can't understand it, or maybe you are not sure, then i will make a simple image of it, maybe it will help.

                                  Yes, please do.

                                  Both @J-Hilk and myself have tried to understand your question, and we both gave you some code. If the code is not what you want, that means we can't understand what you want. A simple image will be very helpful.

                                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                  1 Reply Last reply
                                  3
                                  • L Offline
                                    L Offline
                                    Loc888
                                    wrote on last edited by
                                    #17
                                    This post is deleted!
                                    1 Reply Last reply
                                    0
                                    • L Offline
                                      L Offline
                                      Loc888
                                      wrote on last edited by
                                      #18

                                      Image1: https://tinypic.pl/v6f0sy6qi612
                                      Image2: https://tinypic.pl/hwvlldlzqaah
                                      Image3: https://tinypic.pl/zs4be25yzsjr <-- This one is the most important.

                                      JKSHJ 1 Reply Last reply
                                      1
                                      • L Loc888

                                        Image1: https://tinypic.pl/v6f0sy6qi612
                                        Image2: https://tinypic.pl/hwvlldlzqaah
                                        Image3: https://tinypic.pl/zs4be25yzsjr <-- This one is the most important.

                                        JKSHJ Offline
                                        JKSHJ Offline
                                        JKSH
                                        Moderators
                                        wrote on last edited by JKSH
                                        #19

                                        @Loc888 said in Path length instead of degrees.:

                                        Image1: https://tinypic.pl/v6f0sy6qi612
                                        Image2: https://tinypic.pl/hwvlldlzqaah
                                        Image3: https://tinypic.pl/zs4be25yzsjr <-- This one is the most important.

                                        Great, thank you.

                                        You can use the findDegrees() function that I wrote before, right?

                                        double findDegrees(double fullCircleLength, double pathLength) {
                                            double ratio = fullCircleLength / pathLength;
                                            double angle = 360 / ratio;
                                        
                                            return angle;
                                        }
                                        

                                        The function calls below will give you the same results:

                                        • this->ball_P->setRotation( findDegrees(50000, 25000) );
                                        • this->ball_P->setRotation(180);

                                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                        L 1 Reply Last reply
                                        1
                                        • JKSHJ JKSH

                                          @Loc888 said in Path length instead of degrees.:

                                          Image1: https://tinypic.pl/v6f0sy6qi612
                                          Image2: https://tinypic.pl/hwvlldlzqaah
                                          Image3: https://tinypic.pl/zs4be25yzsjr <-- This one is the most important.

                                          Great, thank you.

                                          You can use the findDegrees() function that I wrote before, right?

                                          double findDegrees(double fullCircleLength, double pathLength) {
                                              double ratio = fullCircleLength / pathLength;
                                              double angle = 360 / ratio;
                                          
                                              return angle;
                                          }
                                          

                                          The function calls below will give you the same results:

                                          • this->ball_P->setRotation( findDegrees(50000, 25000) );
                                          • this->ball_P->setRotation(180);
                                          L Offline
                                          L Offline
                                          Loc888
                                          wrote on last edited by
                                          #20

                                          @JKSH Ok, but it will work with if i wanna move it by 50,03674 or something like this? I saw it's double, but i am not sure.

                                          JKSHJ 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