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. Graphic of function y=sin(1/x)
Forum Updated to NodeBB v4.3 + New Features

Graphic of function y=sin(1/x)

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 809 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.
  • T Offline
    T Offline
    Troyer
    wrote on last edited by
    #1

    Good evening!
    I need to display the graph somehow:
    y = sin(1/x); 0.9 <= x <= 2.8; Δx = 0.2;
    Does anyone know what formula to apply to this function via code? :)

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

      Hi
      That it the formula.
      it says
      y = sin(1/x);
      and x goes from 0.9 to 2.8 in step 0.2

      for for each value in x, you can get the y
      and then paint it your self with QPainter or use QChart.

      So im not sure what you are asking ?

      T 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        That it the formula.
        it says
        y = sin(1/x);
        and x goes from 0.9 to 2.8 in step 0.2

        for for each value in x, you can get the y
        and then paint it your self with QPainter or use QChart.

        So im not sure what you are asking ?

        T Offline
        T Offline
        Troyer
        wrote on last edited by
        #3

        I just don't really understand the condition, other than y=sin(1/x). And if I draw using QPainter, I don't even know how to implement it using this formula. After all, you need to not just draw from the line, but somehow enter accurate data.

        My problem is that I don't know how to implement this formula via QPainter :\

        mrjjM 1 Reply Last reply
        0
        • T Troyer

          I just don't really understand the condition, other than y=sin(1/x). And if I draw using QPainter, I don't even know how to implement it using this formula. After all, you need to not just draw from the line, but somehow enter accurate data.

          My problem is that I don't know how to implement this formula via QPainter :\

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

          @Troyer

          Hi
          Well it says to do like this

              double y = 0;    
              double deltax = 0.2;
              for (double x = 0.9; x <= 2.8; x += deltax ) {
              y =  sin(1.0 / x);
              paint.drawPoint( 100 + int(x),100 + int(y));
              }
          

          However, since its very small values, drawing them directly is not very visible since
          its super tiny.

          So might be better to use QtCharts as it can zoom.

          1 Reply Last reply
          2
          • Y Offline
            Y Offline
            Yet Zio
            wrote on last edited by
            #5

            You could use LineSeries with ChartView natively with your function. You can use a for loop for plotting each point depending on how you would like to Plot it, finally set the graph. First of all read the docs for functions if something similar is available, else reply back to this thread

            ```Securing is more important than developing```

            1 Reply Last reply
            2

            • Login

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