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. Is there a Qt class representing a 2D ray (point and direction)?
QtWS25 Last Chance

Is there a Qt class representing a 2D ray (point and direction)?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 382 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.
  • S Offline
    S Offline
    sasl
    wrote on last edited by
    #1

    This is a quick question about the availability of a suitable geometric class in Qt. I tried searching but didn't find anything useful, but it might be because I don't know the correct terminology. Any help would be appreciated!

    I want to represent a ray (half-line) defined as a 2D point (QPointF) and a direction (e.g. an angle or vector in 2D). This is different to a QLineF since it has only one point and the other end goes off into infinity in the defined direction. Does such a class exist in Qt already? It seems like there should be one. I'd ideally like to benefit from built-in methods for rotating such an object instead of rolling my own.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • S Offline
        S Offline
        sasl
        wrote on last edited by
        #3

        Following up on this - I think there is not such a class and it seems like there won't be one, mainly because there is even not a vector class in QtCore (only QVector2D in QtGui, intended for GUI stuff like vertexes and not geometry calculations). The QLine class has a unitVector() function which returns another QLine. Since there's not even a vector class I expect there will not be a ray class. If anyone knows for sure, I'd still be interested to hear.

        kshegunovK J.HilkJ 2 Replies Last reply
        0
        • S sasl

          Following up on this - I think there is not such a class and it seems like there won't be one, mainly because there is even not a vector class in QtCore (only QVector2D in QtGui, intended for GUI stuff like vertexes and not geometry calculations). The QLine class has a unitVector() function which returns another QLine. Since there's not even a vector class I expect there will not be a ray class. If anyone knows for sure, I'd still be interested to hear.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @sasl said in Is there a Qt class representing a 2D ray (point and direction)?:

          Following up on this - I think there is not such a class and it seems like there won't be one, mainly because there is even not a vector class in QtCore (only QVector2D in QtGui, intended for GUI stuff like vertexes and not geometry calculations). The QLine class has a unitVector() function which returns another QLine. Since there's not even a vector class I expect there will not be a ray class. If anyone knows for sure, I'd still be interested to hear.

          There's QVector2D, QVector3D and QVector4D. I really don't understand the question though, a "ray" is the same as a line - 2 vectors (or 2 points for that matter). Written in parametric form the only difference is that the scaling parameter for a ray goes to positive only, while for a line it can go positive and negative. In linear algebra there's no distinction between a point and a vector, as a (radius) vector identifies a specific point and vice versa. Transforming points is the same as transforming vectors, which is simply a matrix operator applied in the vector space. Finally Qt isn't a proper geometry library, it provides what is needed for graphics, not for general purpose calculations.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          1
          • S sasl

            Following up on this - I think there is not such a class and it seems like there won't be one, mainly because there is even not a vector class in QtCore (only QVector2D in QtGui, intended for GUI stuff like vertexes and not geometry calculations). The QLine class has a unitVector() function which returns another QLine. Since there's not even a vector class I expect there will not be a ray class. If anyone knows for sure, I'd still be interested to hear.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @sasl
            there is also QMatrix
            https://doc.qt.io/qt-5/qmatrix.html


            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
            1

            • Login

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