Sine wave with half circle waves?

3absh3absh Member Posts: 601

I need a function where the Sine wave is thickened to the point where when the positive and negative waves are half circles.

Comments

  • tintrantintran Member Posts: 453

    you didn't specify what diameter of the circle is..
    but this should help you.
    It has diameter of 4.

    I first started with a graph of sqrt(4 - (x-2)^2)
    then i played around with floor and coefficients to get the other 2 graphs and then i modded the values to get repeating pattern, then added into my original equation.

  • 3absh3absh Member Posts: 601
    edited July 2015

    @tintran said:
    you didn't specify what diameter of the circle is..
    but this should help you.
    It has diameter of 4.

    I first started with a graph of sqrt(4 - (x-2)^2)
    then i played around with floor and coefficients to get the other 2 graphs and then i modded the values to get repeating pattern, then added into my original equation.

    thanks tintran,
    What I did was simply square root the Sine function.
    I haven't experimented enough with it, but it seems the smaller the exponent the flatter the wave appears.
    I haven't reached the precise exponents where it's 100% circular, I'm assuming it has something to do with pi, probably

    y=(sin(x))^(1/pi)

  • SLOCM3ZSLOCM3Z Member Posts: 797

    @abuabed84 said:
    y=(sin(x))^(1/pi)

    woah

  • 3absh3absh Member Posts: 601

    The circular Sine wave during implementation was a bit too narrow for me.

    I ended up using

    y=(Sin(x))^0.6

  • tintrantintran Member Posts: 453
    edited July 2015

    i don't expect any exponent that will get you perfect circle because by using sin(x) you're specifying x as an angle and not x coordinate of a circle (but i could be wrong :D)
    I arrived at mine by using y^2+x^2 = r where r is just a radius using pythegorean theorem.
    here's a graph to show the negative of my curve as well, as you can see it's perfect circle.
    If you want you can just play with the coefficients to get the circle of the proper radius size.

    and one with actual circle formula to compare

  • 3absh3absh Member Posts: 601
    edited July 2015

    Excellent man, thanks a lot

  • 3absh3absh Member Posts: 601

    @tintran said:
    i don't expect any exponent that will get you perfect circle because by using sin(x) you're specifying x as an angle and not x coordinate of a circle (but i could be wrong :D)

    I'm pretty sure you can draw half a circle with a sine wave, I've seen it before in college, I just can't remember the function.

  • 3absh3absh Member Posts: 601

    @tintran said:
    i don't expect any exponent that will get you perfect circle because by using sin(x) you're specifying x as an angle and not x coordinate of a circle (but i could be wrong :D)

    As long as it's a variable, the possibilities are limitless.

  • tintrantintran Member Posts: 453

    As i said, i could be wrong but until i see the proof, i don't think it's possible.

  • tintrantintran Member Posts: 453
    edited July 2015

    I got curious and tried to prove myself wrong but so far, i can't
    I got pretty close though

    it's close enough, I'd rather use your equation because it's simpler.

  • SocksSocks London, UK.Member Posts: 12,822

    You could also simply rotate a moving actor in opposite directions every 180° . . . hold on let me try it out . . .

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    Here you go, I didn't use any clever maths, so I made up for it with an undulating rainbow coloured line :tongue:

  • tintrantintran Member Posts: 453

    @Socks said:
    Here you go, I didn't use any clever maths, so I made up for it with an undulating rainbow coloured line :tongue:

    cool.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @tintran said:
    cool.

    Cheers.

    P.S. You're right that sin(x) specifies x as an angle, so it's not clear how this could produce a circle.

    This circle fill question had similar demands:

    http://forums.gamesalad.com/discussion/67889/mathematical-expression-question-for-circle-fill

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    The formula goes something like this:

    150+((-1)^floor(( self.Position.X /(2* self.r ))-.5))(sqrt(( self.r ^2)-(( self.Position.X -((2 self.r )floor((( self.Position.X /(2 self.r ))+.5))))^2)))

    "150" is the horizontal middle
    "self.r" is the radius

    "((-1)^floor(( self.Position.X /(2* self.r ))-.5))" is used to flip from 1 to -1 so that you get the upper part and the lower part. Without it, you just get a semicircle.

    The rest is an equation for a semicircle.

    Here is a demo.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @RThurman

    Sure that's clever, and it actually works and is mathematically sound and all that, but my example had a rainbow coloured line.

    :tongue:

  • LovejoyLovejoy Member Posts: 2,078

    Battle of the geniuses. I bet that 1% of the GS population understands this black magic.

    Fortuna Infortuna Forti Una

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2015

    rainbows?
    Rainbows!
    RAINBOWS!!

    I forgot the stinking rainbows!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2015

    @Lovejoy said:
    Battle of the geniuses. I bet that 1% of the GS population understands this black magic.

    Sorry -- no geniuses here! I just Googled something like "circle wave form" and found an image that looked promising. Then shoved the formula I found here into GameSalad:
    http://math.stackexchange.com/questions/44329/function-for-concatenated-semicircles

    And it worked!

  • SocksSocks London, UK.Member Posts: 12,822

    @RThurman said:

    rainbows?
    Rainbows!
    RAINBOWS!!

    I forgot the stinking rainbows!

    You're not going to get very far in life without razzmatazz and showmanship, sure a doctor can carry out a heart bypass, but what a patent wants to wake up with is a bypass scar in the shape of dolphin.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2015

    @Socks said:
    You're not going to get very far in life without razzmatazz and showmanship, sure a doctor can carry out a heart bypass, but what a patent wants to wake up with is a bypass scar in the shape of dolphin.

    Yes, a dolphin shaped heart-bypass scar is just what I need to impress the ladies!

    Hmmm..... I wonder what the function is for creating a dolphin shaped plot?

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @RThurman said:
    Hmmm..... I wonder what the function is for creating a dolphin shaped plot?

    AAA *sin(game.time *BBB)+CCC

    You just need to play around with the numbers.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @Socks said:
    AAA *sin(game.time *BBB)+CCC
    You just need to play around with the numbers.

    yup... should have seen that one coming around the bend
    :)

Sign In or Register to comment.