#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Sine wave with half circle waves?

Posts: 510Member, PRO

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

• Posts: 453Member

you didn't specify what diameter of the circle is..
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.

• Posts: 510Member, PRO
edited July 2015

@tintran said:
you didn't specify what diameter of the circle is..
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)

• Posts: 797Member

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

woah

• Posts: 510Member, PRO

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

I ended up using

y=(Sin(x))^0.6

• Posts: 453Member
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 )
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

• Posts: 510Member, PRO
edited July 2015

Excellent man, thanks a lot

• Posts: 510Member, PRO

@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 )

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.

• Posts: 510Member, PRO

@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 )

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

• Posts: 453Member

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

• Posts: 453Member
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.

• London, UK.Posts: 12,822Member

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

• London, UK.Posts: 12,822Member
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

• Posts: 453Member

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

cool.

• London, UK.Posts: 12,822Member
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:

• Posts: 2,822Member, Sous Chef, PRO

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

"((-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.

• London, UK.Posts: 12,822Member
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.

• Posts: 2,782Member, PRO
• Posts: 2,078Member

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

Fortuna Infortuna Forti Una

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

rainbows?
Rainbows!
RAINBOWS!!

I forgot the stinking rainbows!

• Posts: 2,822Member, Sous Chef, PRO
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!

• London, UK.Posts: 12,822Member

@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.

• Posts: 2,822Member, Sous Chef, PRO
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?

• London, UK.Posts: 12,822Member
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.

• Posts: 2,822Member, Sous Chef, PRO

@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