+ Reply to Thread
Results 1 to 14 of 14

Thread: qt math support

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Question qt math support

    Are there any platform independent trigonometric functions availabe in qt/qtopia? Basicaly I need sinus and cosinus.
    Last edited by MarkoSan; 1st December 2007 at 19:55.
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,507 Times in 1,384 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt math support

    What about stdmath?
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    ittod (14th August 2013)

  4. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt math support

    I am thinking about it, but will then the project be able to be compiled as qtopia application?
    Qt 5.3 Opensource & Creator 3.1.2

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    31,450
    Thanks
    3
    Thanked 4,719 Times in 4,520 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: qt math support

    Hmm... the math library is in glibc, so... unless you strip glibc out of sin() and cos() they'll be there.

  6. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt math support

    So, wysotta, you meant stdmath is in glibc?

    I've checked now include files from installed mingw, I haven't found stdmath.h, but I've found math.h. Is this math.h also linked into glibc?
    Last edited by MarkoSan; 1st December 2007 at 22:58.
    Qt 5.3 Opensource & Creator 3.1.2

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    31,450
    Thanks
    3
    Thanked 4,719 Times in 4,520 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: qt math support

    Look at the include file of what you were given...
    http://www.cppreference.com/stdmath/sin.html

  8. #7
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt math support

    I know what sin() is, but what I wanted to know, are stdmath and math.h SAME headers? Are both linked in glibc?
    Qt 5.3 Opensource & Creator 3.1.2

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,507 Times in 1,384 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt math support

    In C++ programs you would include <cmath>, which is the C++ version of the standard library header. Its contents are (mostly) the same as <math.h>, but it uses the std namespace.
    J-P Nurmi

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    31,450
    Thanks
    3
    Thanked 4,719 Times in 4,520 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: qt math support

    Quote Originally Posted by MarkoSan View Post
    I know what sin() is, but what I wanted to know, are stdmath and math.h SAME headers? Are both linked in glibc?
    If you look at the code in the link, you'll see it includes <math.h> - sin(), cos(), etc. are just C functions, you can use them in C++ apps as well. <cmath> just embedds the function names into the std namespace (as J-P already explained) to avoid potential name clash.

  11. #10
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Question Re: qt math support

    Ok, I know that, but, once more:

    Are they any troubles to be expected when porting existing qt application that uses mentioned trigonometric functions to device, which will use embedded linux (qnx rtos) and qtopia? Does anyone have experience with this?
    Qt 5.3 Opensource & Creator 3.1.2

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    31,450
    Thanks
    3
    Thanked 4,719 Times in 4,520 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: qt math support

    No, you won't get any troubles, provided that the device has a glibc implementation that contains sin() and cos(). As glibc is open source I can't guarantee that every possible implementation of glibc has it. It probably does though.

  13. The following user says thank you to wysota for this useful post:

    MarkoSan (2nd December 2007)

  14. #12
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt math support

    So, wysotta, glibc then is part of os? I need to contact the manufacturer of qnx rtos and they will provide me with needed info? In worst case scenario I will be forced to write a custom code that will compute sinus and cosinus with help of Taylor series.
    Qt 5.3 Opensource & Creator 3.1.2

  15. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    31,450
    Thanks
    3
    Thanked 4,719 Times in 4,520 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: qt math support

    Just use those functions. If your code doesn't link, you'll be worrying. I don't see why someone would want to strip out sin and cos out of glibc, so there is a 99% chance it will work. But sometimes one needs to strip out as much as possible to fit some code onto a limited storage or working space, so I guess someone could actually think "hey, I don't need trygonometric functions on my PDA, let's cut them out to save some RAM".

  16. The following user says thank you to wysota for this useful post:

    MarkoSan (2nd December 2007)

  17. #14
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    631
    Thanks
    94
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt math support

    Ok , you've just made my day better. Thanks, but still i will leave a comment in a code as POSSIBLE TODO. Now this post can be closed.
    Qt 5.3 Opensource & Creator 3.1.2

+ Reply to Thread

Similar Threads

  1. Qt configure with msvc.net
    By jivanr in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 08:17
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. Qt static library with jpeg support
    By vishal.chauhan in forum Installation and Deployment
    Replies: 2
    Last Post: 11th May 2007, 06:53
  4. Compile QT4.2.2 with MySQL on Mac OS
    By asd in forum Installation and Deployment
    Replies: 7
    Last Post: 12th February 2007, 14:50
  5. Qt and jpg support in Linux ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2007, 23:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts