Each Choice was animated by varying the boundaries of the s &
t values for the hump displacement over time.
Choice 1: Is based on the formula of a circle.
s2 + t2 = radius2
s2 = radius2 - t2
s = (radius2 - t2)/s
///this looks similar to the formula used below.
Choice #1
Choice #2
Choice #3
Choice #4
Choice #5
Code
displacement rsl_tests
(float Km = 0.1,
/* displacement magnitude */
top_edge = 0.4,
lower_edge = 0.6,
radius = 0.8,
choice = 1 )
{
float hump = 0;
normal n;
/* STEP 1 - make a copy of the surface
normal one unit in length */
n = normalize(N);
/* STEP 2 - calculate an appropriate
value for the displacement */
if(choice == 1){
/* EX #1*/
if(s < (radius -(t * t)) / s) {
hump = -1;
}
}
else if(choice == 2){
/* EX #2*/
if(t < top_edge || t > lower_edge ||
s > top_edge && s < lower_edge){
hump = 1;
}
}
else if(choice == 3){
/* EX #3*/
if(t > top_edge && t < lower_edge ||
s > top_edge && s < lower_edge){
hump = 1;
}
}
else if(choice == 4){
/* EX #4*/
if(t > top_edge && t < lower_edge){
hump = 1 - s;
}
}
else if(choice == 5){
/* EX #5*/
if(t > top_edge && t < lower_edge &&
s > top_edge && s < lower_edge){
hump = -1;
}
}
/* STEP 3 - calculate the new position of the
surface point, "P" based on the value of hump */
P = P - n * hump * Km;
/* STEP 4 - calculate the new orientation
of the surface normal */
N = calculatenormal(P);
}