Option type: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Dkasak
→‎The option monad: Fix error in fmap type (it should accept two arguments and return a monad, not a function from monad to monad).
 
en>Nbarth
nullable
Line 1: Line 1:
[[File:Smoothstep and Smootherstep.svg|thumb|A plot of the smoothstep(x) and smootherstep(x) functions.]]
'''Smoothstep''' is a scalar [[interpolation]] function commonly used in [[computer graphics]]<ref>[http://msdn.microsoft.com/en-us/library/bb509658(VS.85).aspx Smoothstep at Microsoft Developer Network]</ref><ref>[http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.40.05.pdf GLSL Language Specification, Version 1.40]</ref> and [[Game engine|video game engines]].<ref>[http://unity3d.com/support/documentation/ScriptReference/Mathf.SmoothStep.html Unity game engine SmoothStep documentation]</ref> The function interpolates [[Smooth function|smoothly]] between two input values based on a third one that should be between the first two. The returned value is clamped between 0 and 1.


The slope of the smoothstep function tends toward zero at both edges.  This makes it easy to create a sequence of transitions using smoothstep to interpolate each segment rather than using a more sophisticated or expensive interpolation technique.


Tens and thousands of people in Usa are real estate agents. Many real estate agents work with a current real estate firm or they their build their own. In several states a real estate agent is needed to obtain a real estate license before they being selling houses. Obtaining a genuine estate license might be problematic for some individuals; nevertheless, many have a problem with getting consumers when they have acquired their license. <br><br>A common mistake that lots of business owners make isn&quot;t using the internet to its fullest potential. The internet is an amazing source of information; however, it may also be utilized to promote a small business. For most companies to be successful they have to find out about website development. Real estate agents will be allowed by fully understanding real estate website development to-use the internet to their advantage. <br><br>One of the most readily useful ways to find out about property site development is by exploring it through the net. If you are thinking about developing your own website there are number of online learning resources related to real estate website development. To get other interpretations, consider having a gander at: [http://www.streetfire.net/profile/realestatenws.htm realestatenws - StreetFire Member in US]. Many of these online resources are available in the shape of-a web site or online concept forum. Nearly all these boards or sites should be free to use. It is possible a few sites may require you to purchase getting info on real estate website development; however, you really shouldnt need to. There&quot;s genuinely no reasons why you should pay for just acquiring information each time a many other web sites will allow you to acquire the information for free. <br><br>When you&quot;ve reviewed real-estate website development you can begin the task of developing your own website. If you are unhappy with the caliber of work or do not believe that your website style is professional enough you might wish to consider hiring outside help. This outside help can be had in a number of ways. Browsing To [http://www.hummaa.com/user/rentballitojqq Hald Garner Dashboard, Music Profile, Friends, Playlists , Messages, Comments, Favour] certainly provides lessons you should tell your brother. <br><br>You might have discovered a couple of sites offering real estate website themes when you were researching real estate website growth. Real estate layouts can generally be bought for around a hundred dollars or less. They are used as a model o-r information for having a site. Once a property site design has been acquired you will generally just have to type in your organization information. Real estate website templates are popular because they are a straightforward and rather low-priced method for real estate agents or agencies to get a website developed. You may decide to hire a website designer if you don&quot;t have the time to build up your own personal website or even to use a real estate design. A real estate website designer is normally experienced in real estate website development. For a fee they can create a professional looking property website for you. <br><br>Studying, studying, and understanding real estate site development won&quot;t only make you more proficient, however it may also help your organization. Company sites are demonstrated to help increase the income and earnings of the company. You should have one today created if you&quot;re currently running a business without a company web site..<br><br>If you have any concerns pertaining to exactly where and how to use Veterans Health Administration ([https://FultonkjYezkb.jux.com FultonkjYezkb.Jux.Com]), you can get hold of us at the web page.
As pointed out in [[Microsoft Developer Network|MSDN]] and [[OpenGL]] documentation, smoothstep implements cubic [[Hermite interpolation]] after doing a clamp:
 
:<math> \operatorname{smoothstep}(t) = 3t^2 - 2t^3 </math>
 
An example implementation provided by AMD<ref>[http://ati.amd.com/developer/SIGGRAPH03/ATI_HardwareShading_SIGGRAPH2003.pps ATI R3x0 Pixel Shaders]</ref> follows.
 
<source lang="c">
float smoothstep(float edge0, float edge1, float x)
{
    // Scale, bias and saturate x to 0..1 range
    x = saturate((x - edge0)/(edge1 - edge0));
    // Evaluate polynomial
    return x*x*(3 - 2*x);
}
</source>
 
== Variations ==
[[Ken Perlin]] suggests<ref>[http://www.amazon.com/Texturing-Modeling-Third-Procedural-Approach/dp/1558608486 Texturing and Modeling, Third Edition: A Procedural Approach]</ref> an improved version of the smoothstep function which has zero 1st and 2nd order derivatives at t=0 and t=1:
 
:<math> \operatorname{smootherstep}(t) = 6t^5 - 15t^4 + 10t^3 </math>
 
Reference implementation:
<source lang="c">
float smootherstep(float edge0, float edge1, float x)
{
    // Scale, and clamp x to 0..1 range
    x = clamp((x - edge0)/(edge1 - edge0), 0.0, 1.0);
    // Evaluate polynomial
    return x*x*x*(x*(x*6 - 15) + 10);
}
</source>
 
== Origin ==
 
=== 3rd order equation ===
 
We start with a generic third order [[polynomial]] function and its first [[derivative]]:
:<math>\begin{alignat}{9}
f(t)  &&\; = \;&&  a_3 t^3 &&\; + \;&& a_2 t^2 &&\; + \;&& a_1 t &&\; + \;&& a_0 & \\
f'(t) &&\; = \;&& 3 a_3 t^2 &&\; + \;&& 2 a_2 t &&\; + \;&& a_1 &
\end{alignat}</math>
 
Applying the desired values for the function at both endpoints we get:
:<math>\begin{alignat}{13}
f(0) &&\; = \;&& 0 \;\;\;\;\;&& \Rightarrow &&\;\;\;\;\;  0 \;&& + &&\;  0 \;&& + &&\;  0 \;&& + &&\; a_0 &&\; = \;&& 0 & \\
f(1) &&\; = \;&& 1 \;\;\;\;\;&& \Rightarrow &&\;\;\;\;\; a_3 \;&& + &&\; a_2 \;&& + &&\; a_1 \;&& + &&\; a_0 &&\; = \;&& 1 &
\end{alignat}</math>
 
Applying the desired values for the first derivative of the function at both endpoints we get:
:<math>\begin{alignat}{11}
f'(0) &&\; = \;&& 0 \;\;\;\;&& \Rightarrow &&\;\;\;\;    0 \;&& + &&\;    0 \;&& + &&\; a_1 \;&& = \;&& 0 & \\
f'(1) &&\; = \;&& 0 \;\;\;\;&& \Rightarrow &&\;\;\;\; 3 a_3 \;&& + &&\; 2 a_2 \;&& + &&\; a_1 \;&& = \;&& 0 &
\end{alignat}</math>
 
Solving the system of 4 unknowns formed by the last 4 equations we obtain the values of the polynomial coefficients:
:<math>a_0 = 0 , \;\;\;\;\;\; a_1 = 0 , \;\;\;\;\;\; a_2 = 3 , \;\;\;\;\;\; a_3 = -2</math>
 
Introducing these coefficients back into the first equation gives the third order smoothstep function:
:<math>f(t) = -2t^3 + 3t^2</math>
 
=== 5th order equation ===
 
We start with a generic fifth order [[polynomial]] function, its first derivative and its second derivative:
:<math>\begin{alignat}{13}
f(t)  &&\; = \;&&    a_5 t^5 &&\; + \;&&    a_4 t^4 &&\; + \;&&  a_3 t^3 &&\; + \;&&  a_2 t^2 &&\; + \;&& a_1 t &&\; + \;&& a_0 & \\
f'(t)  &&\; = \;&&  5 a_5 t^4 &&\; + \;&&  4 a_4 t^3 &&\; + \;&& 3 a_3 t^2 &&\; + \;&& 2 a_2 t  &&\; + \;&& a_1  & \\
f''(t) &&\; = \;&& 20 a_5 t^3 &&\; + \;&& 12 a_4 t^2 &&\; + \;&& 6 a_3 t  &&\; + \;&& 2 a_2    &
\end{alignat}</math>
 
Applying the desired values for the function at both endpoints we get:
:<math>\begin{alignat}{17}
f(0) &&\; = \;&& 0 \;\;\;\;\;&& \Rightarrow &&\;\;\;\;\;  0 \;&& + &&\;  0 \;&& + &&\;  0 \;&& + &&\;  0 \;&& + &&\;  0 \;&& + &&\; a_0 &&\; = \;&& 0 & \\
f(1) &&\; = \;&& 1 \;\;\;\;\;&& \Rightarrow &&\;\;\;\;\; a_5 \;&& + &&\; a_4 \;&& + &&\; a_3 \;&& + &&\; a_2 \;&& + &&\; a_1 \;&& + &&\; a_0 &&\; = \;&& 1 &
\end{alignat}</math>
 
Applying the desired values for the first derivative of the function at both endpoints we get:
:<math>\begin{alignat}{15}
f'(0) &&\; = \;&& 0 \;\;\;\;&& \Rightarrow &&\;\;\;\;    0 \;&& + &&\;    0 \;&& + &&\;    0 \;&& + &&\;    0 \;&& + &&\; a_1 \;&& = \;&& 0 & \\
f'(1) &&\; = \;&& 0 \;\;\;\;&& \Rightarrow &&\;\;\;\; 5 a_5 \;&& + &&\; 4 a_4 \;&& + &&\; 3 a_3 \;&& + &&\; 2 a_2 \;&& + &&\; a_1 \;&& = \;&& 0 &
\end{alignat}</math>
 
Applying the desired values for the second derivative of the function at both endpoints we get:
:<math>\begin{alignat}{15}
f''(0) &&\; = \;&& 0 \;\;\;\;&& \Rightarrow &&\;\;\;\;      0 \;&& + &&\;      0 \;&& + &&\;    0 \;&& + &&\; 2 a_2 \;&& = \;&& 0 & \\
f''(1) &&\; = \;&& 0 \;\;\;\;&& \Rightarrow &&\;\;\;\; 20 a_5 \;&& + &&\; 12 a_4 \;&& + &&\; 6 a_3 \;&& + &&\; 2 a_2 \;&& = \;&& 0 &
\end{alignat}</math>
 
Solving the system of 6 unknowns formed by the last 6 equations we obtain the values of the polynomial coefficients:
:<math>a_0 = 0 , \;\;\;\;\;\; a_1 = 0 , \;\;\;\;\;\; a_2 = 0 , \;\;\;\;\;\; a_3 = 10 , \;\;\;\;\;\; a_4 = -15 , \;\;\;\;\;\; a_5 = 6</math>
 
Introducing these coefficients back into the first equation gives the fifth order smoothstep function:
:<math>f(t) = 6t^5 - 15t^4 + 10t^3</math>
 
== References ==
{{reflist}}
 
== External links ==
* [http://www.fundza.com/rman_shaders/smoothstep/index.html Using smoothstep] (in the [[RenderMan Shading Language]]) by Prof. Malcolm Kesson.
* [http://sol.gfxile.net/interpolation/ Interpolation tricks] by Jari Komppa
 
[[Category:Computer graphics algorithms]]

Revision as of 12:00, 5 October 2013

A plot of the smoothstep(x) and smootherstep(x) functions.

Smoothstep is a scalar interpolation function commonly used in computer graphics[1][2] and video game engines.[3] The function interpolates smoothly between two input values based on a third one that should be between the first two. The returned value is clamped between 0 and 1.

The slope of the smoothstep function tends toward zero at both edges. This makes it easy to create a sequence of transitions using smoothstep to interpolate each segment rather than using a more sophisticated or expensive interpolation technique.

As pointed out in MSDN and OpenGL documentation, smoothstep implements cubic Hermite interpolation after doing a clamp:

An example implementation provided by AMD[4] follows.

float smoothstep(float edge0, float edge1, float x)
{
    // Scale, bias and saturate x to 0..1 range
    x = saturate((x - edge0)/(edge1 - edge0)); 
    // Evaluate polynomial
    return x*x*(3 - 2*x);
}

Variations

Ken Perlin suggests[5] an improved version of the smoothstep function which has zero 1st and 2nd order derivatives at t=0 and t=1:

Reference implementation:

float smootherstep(float edge0, float edge1, float x)
{
    // Scale, and clamp x to 0..1 range
    x = clamp((x - edge0)/(edge1 - edge0), 0.0, 1.0);
    // Evaluate polynomial
    return x*x*x*(x*(x*6 - 15) + 10);
}

Origin

3rd order equation

We start with a generic third order polynomial function and its first derivative:

Applying the desired values for the function at both endpoints we get:

Applying the desired values for the first derivative of the function at both endpoints we get:

Solving the system of 4 unknowns formed by the last 4 equations we obtain the values of the polynomial coefficients:

Introducing these coefficients back into the first equation gives the third order smoothstep function:

5th order equation

We start with a generic fifth order polynomial function, its first derivative and its second derivative:

Applying the desired values for the function at both endpoints we get:

Applying the desired values for the first derivative of the function at both endpoints we get:

Applying the desired values for the second derivative of the function at both endpoints we get:

Solving the system of 6 unknowns formed by the last 6 equations we obtain the values of the polynomial coefficients:

Introducing these coefficients back into the first equation gives the fifth order smoothstep function:

References

43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

External links