Thread: ...simple sine wave?

  1. #16
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Ok, swell. I've corrected the original equation, added some fine-tuning control over it, and animated it to boot. Not a bad little proggie, actually.

    Oh, and thanks again to all the math geeks who helped me out.

    - cheers.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #17
    Shadow12345
    Guest
    I never thought I'd get to show this proggie off, but this is an appropriate place. I did it when we were talking about electro magnetic radiation in chemistry.

    oh and sebastanti your program just closes when I go to run it so I have no clue what you actually did in your program

  3. #18
    Shadow12345
    Guest
    here is a second version i just made. I'll give 20 bucks to anyone who can look at it for 20 mins without barfing.

  4. #19
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Interesting. But what is it? It sort of looks like one of those hippie "trip" movies you're supposed to watch on LSD.

    So, did anyone else have trouble running my program?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #20
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    >> here is a second version i just made. I'll give 20 bucks to anyone who can look at it for 20 mins without barfing. <<

    I'm a bit disappointed. I could do 20 minutes...er--I mean did 20 minutes where's my money

    [edit]
    Btw, you program looks much nicer Sabastiani.
    [/edit]
    Last edited by master5001; 12-13-2002 at 02:52 AM.

  6. #21
    Shadow12345
    Guest
    yeah your program looks pretty cool, it took me forever to figure out how to change the things in the textbox lol

    would mine be better if you could change the amplitutde, wavelength, frequency, sleeptime, etc in my prog?

  7. #22
    Shadow12345
    Guest
    I have a question, what exactly is the 'res' and what did you use sebastiani (windows GDI?) for the waves.

  8. #23
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I actually watched the your animation for some time. Interesting patterns. And sure, it'd be cool if you could tinker with the settings. So what did you use to code it in and what are the algo's based on?

    I used straight Win32, no DX or anything, but luckily I could make use of a C++ library I've been working on, which was rewarding.

    'Rez' is just the relative resolution, or how often the calculation is performed, with 1 (pixel) being the highest resolution. Interesting effect when you set rez, amp, and freq to the same values, too.

    I really suck at math and that's what I appreciate about the program, is that I do enjoy tangible applications of mathematical principles...anyway, I would like it to eventually parse equations and add some other features too. Let me know if you have any suggestions.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #24
    Shadow12345
    Guest
    So what did you use to code it in and what are the algo's based on?
    just win32api and opengl.

    The equations used in both our apps are almost exactly the same, except with mine they are all hard coded into the program. Color (which is randomly assigned each frame creating seizure causing flashing),and length of the spiral are also hard coded into the program. The biggest difference between the apps is that in mine both the horizontal and vertical movement is controlled by sine waves as a function of time, and it moves over the z axis causing the spiral effects (this should be familiar to people who have played quake II/III because the railgun uses a similar spiral except I think the amplitude decreases as z increases). Yours is better because you can actually interact with it, mine is just like a screensaver.


    applications of mathematical principles...anyway, I would like it to eventually parse equations and add some other features too. Let me know if you have any suggestions.
    ohhhhh boy there are so many cool things you can draw with equations. Here's something I did using inverse power models, i.e
    y = 'size' / x^power
    i.e in this attached proggie it's
    25/time^2; for the first
    and 50/time^2 for the second
    the second is farther away and they are both connected by lines in my program

    if you have a ti83 graph the following :
    y1 = 5 /x
    y2= -5 / x
    y3 = 1 / x
    y4 = -1/x
    y5 = 5 / x^2
    y6 = -5 / x^2

    that should give you a good idea

    and also my math teacher was explaning how to use the polarity mode on the ti 83 to produce spirals, ill find more about that next school week

    here is that prog that demonstrates inverse powermodel usage, again everything is hard coded into the program, however you can use the following keys to move around
    left arrow, right arrow, up arrow, down arrow

    if the view gets too screwed up press r to reset the view

  10. #25
    Shadow12345
    Guest
    here is that file

    EDIT: I changed the equation to y = size / time instead of raising it to any power (it looks better this way). so now im not sure what you call it (model of inverse variation?) but it's no longer an inverse power model because I'm not raising anything to any powers.

    yeah...
    Last edited by Shadow12345; 12-14-2002 at 02:47 PM.

  11. #26
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Ok, thanks. I'll post a parsing version sometime next week that will allow equations like these. Also, a grid might be nice, and I need to save settings in the next version too. I wonder how hard z-order implementation would be? I'll look into it.

    Thanks for all of the input.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  12. #27
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    >ohhhhh boy there are so many cool things you can draw with
    >equations.

    I totally agree. Just take a look at fractals. For example, the Mandelbrot set:

    http://www.olympus.net/personal/dewey/mandelbrot.html

  13. #28
    Shadow12345
    Guest
    Originally posted by Shiro
    [B
    I totally agree. Just take a look at fractals. For example, the Mandelbrot set:

    http://www.olympus.net/personal/dewey/mandelbrot.html [/B]
    Cool site. Have you heard of the 'archimedes spiral' or something like that? You draw it by setting your ti 83 to radian mode, then instead of 'func' set it to 'pol' which means polarity. Then you do the sine/cosines of theta (I think that's what it is) and it creates spirals that seem to somewhat resemble those fractals. I might be describing that process a little inaccurately, but chances are if you're in or passed college you've already done it and know what I really mean I'm dumb!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compression/Decompression Wave File and MP3
    By cindy_16051988 in forum Projects and Job Recruitment
    Replies: 51
    Last Post: 04-29-2006, 06:25 AM
  2. writing a wave file from my wave samples
    By Queatrix in forum Windows Programming
    Replies: 2
    Last Post: 12-31-2005, 11:54 PM
  3. Sine Wave Program
    By Stiks in forum C Programming
    Replies: 10
    Last Post: 10-15-2005, 12:35 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Processing a sine wave file
    By subdene in forum C++ Programming
    Replies: 2
    Last Post: 07-12-2004, 03:04 PM