Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
circular s-curve function [HLSL] #357820
02/08/11 20:49
02/08/11 20:49
Joined: Mar 2006
Posts: 2,252
Hummel Offline OP
Expert
Hummel  Offline OP
Expert

Joined: Mar 2006
Posts: 2,252
Hi,
just wanted to share this function I developed for fun.
Converting to any other language shouldnt be the problem.

Lets take a look at the func itself first:
Click to reveal..
Code:
static const float sqrt2_05=sqrt(2.f)*0.5f;
static const float smi=1e-4;

#define floatn float

floatn circular_sCurve(floatn x,float tau)
{
	x-=smi;
	
	float st=sign(sign(-tau)+1);
	floatn p2=step(0.5,x);
	floatn p3=abs(st-p2);
	
	x=fmod(x*2,1);
	x=abs(p3-x);
	
	tau=(1-abs(tau))*sqrt2_05;
	tau=min(tau,sqrt2_05-smi);
	
	float tau2=tau*tau;
	
	float remap0=tau-sqrt(1-2*tau2+tau2);
	float remap1=1-sqrt(1-tau2);
	
	x=-x*remap0+tau;
	
	floatn X=1-sqrt(1-x*x);
	X=(X-remap1)/((1-tau)-remap1);
	
	return (abs(p3-saturate(X))+p2)*0.5;		
}



Input values have to be in the range 0..1 for x and -1..1 for tau.
Output lies also between 0 and 1.

Visualized function with different values for tau:


So,why do I call it 'circular'?
Imagine a simple linear function with a rise of 1 which gets 'deformed' by two 'circles' from the left and the right side of the function, respectively.
The amount of 'deformation' depends on tau. For tau=0 you get a linear function. I hope that is understandable. laugh

You can download a small Demo here where the function is drawn with a dynamic changing tau value.

And eventually the big question:
You: "What the heck is this thing good for?!"
Me: "Well, actually...I´ve no clue^^"
You: "..."
Me: " laugh "

Have fun!


Last edited by Hummel; 02/08/11 21:16.
Re: circular s-curve function [HLSL] [Re: Hummel] #357821
02/08/11 20:51
02/08/11 20:51
Joined: Aug 2002
Posts: 2,183
Germany, BaW�
Rondidon Offline
Expert
Rondidon  Offline
Expert

Joined: Aug 2002
Posts: 2,183
Germany, BaW�
What the heck is this thing good for?!

Re: circular s-curve function [HLSL] [Re: Rondidon] #357822
02/08/11 20:54
02/08/11 20:54
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
LINERIDER!


Click and join the 3dgs irc community!
Room: #3dgs
Re: circular s-curve function [HLSL] [Re: Joozey] #357830
02/08/11 21:29
02/08/11 21:29
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
movement of particle effects, nice looking spells etc.

also you could use the graph you get for alot of other stuff, speed, volume, area etc.


3333333333
Re: circular s-curve function [HLSL] [Re: Quad] #357843
02/08/11 21:41
02/08/11 21:41
Joined: Sep 2003
Posts: 303
Germany
Clemens Offline
Senior Member
Clemens  Offline
Senior Member

Joined: Sep 2003
Posts: 303
Germany
ant not to forget: learning (to program with) mathematics ... laugh

Re: circular s-curve function [HLSL] [Re: Clemens] #357864
02/08/11 22:09
02/08/11 22:09
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
add: Doing fancy procedural texture stuff just for the sake of it. wink


no science involved
Re: circular s-curve function [HLSL] [Re: Rondidon] #357966
02/09/11 13:11
02/09/11 13:11
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Originally Posted By: Rondidon
What the heck is this thing good for?!
People with imagination...


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1