ICE Topology and parametric equations

Here you can find ICE tutorials and learning material
User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 01 Jan 2012, 00:21

A while back, Thiago Costa was using ICE to deform a grid to visualize the graph of a function.

If you are interested, you can found Thiago original thread at:

http://thiagocosta.net/?p=157

We can do the same thing with our Parametric_Sandbox compound. Let's experiment with the grid.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 01 Jan 2012, 00:43

Radial Wave

Here is an example showing radial waves. The distance from the origin is used as an input to a cosine function.

The parameters for this function are:

r = sqrt(u*u + v*v)
x = f(u,v) = u
y = g(u,v) = Cos(r)
z = h(u,v) = v

U_start = -15
U_End = 15
V_Start = -15
V_End - 15

Here is the ICE tree and the result.

We can create a spreading waves by getting the time value from a "frame" node and adding it to the the "r" value before the cosine node.
Attachments
Radial_Wave.jpg
Radial_Wave.jpg (61.28 KiB) Viewed 4636 times
Radial_Wave2.jpg
Radial_Wave2.jpg (116.63 KiB) Viewed 4636 times
Last edited by Daniel Brassard on 01 Jan 2012, 21:15, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 01 Jan 2012, 03:01

In Thiago Costa's blogpost, we see at the beginning a lot of formulas. How do we translate his formulas for use in the Parametric Sandbox?

Easy: his x = u, and his z = v

For example, Thiago first formula is x * z.

For the Parametric Sandbox, the parameters become:

x = f(u,v) = u
y = g(u,v) = (x * z) = (u * v)
z = h(u,v) = v

u_start = -1
u_end = 1
v_start = -1
v_end = 1

Because Thiago is driving a grid to deform with his formulas, we only need to convert his formulas to u and v equivalent and feed the formula result to the y parameter to get the same results has he did.

So for the example above we get the ICE tree and result below.

Now check his second and third formulas .... look familiar?

x^2 + z^2
x^2 – z^2


That's right! Hyperbolic and Elliptic paraboloid! :D
Attachments
Saddle.jpg
Saddle.jpg (53.74 KiB) Viewed 4630 times
Saddle2.jpg
Saddle2.jpg (63.94 KiB) Viewed 4630 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 01 Jan 2012, 20:32

Here is a few of Thiago formulas in Parametric Sandbox ICE tree variations:

x^2 * z^2 (Grid_Elliptic_var1)
x^3 + z^3 (Grid_Elliptic_var2)
sin(x) (Grid_Sine_wave)
Attachments
Grid_Elliptic_var1.jpg
Grid_Elliptic_var1.jpg (88.54 KiB) Viewed 4597 times
Grid_Elliptic_var2.jpg
Grid_Elliptic_var2.jpg (82.39 KiB) Viewed 4597 times
Grid_Sine_wave.jpg
Grid_Sine_wave.jpg (102.77 KiB) Viewed 4597 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 01 Jan 2012, 20:36

And a few more:

cos(x) + cos(z) ^ 2 (Grid_Cosine_wave)
cos(x^2 + z^2) (Grid_Radial_wave2)
sin(x^2 + z^2) (Grid_Radial_wave3)
Attachments
Grid_Cosine_wave.jpg
Grid_Cosine_wave.jpg (82.34 KiB) Viewed 4596 times
Grid_radial_wave2.jpg
Grid_radial_wave2.jpg (94.76 KiB) Viewed 4596 times
Grid_Radial_Wave3.jpg
Grid_Radial_Wave3.jpg (95.06 KiB) Viewed 4596 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 01 Jan 2012, 20:52

If you looked at Thiago formulas, you will see this form:

|x|

These "brakets" are not paranthesis, they are the mathematical representation of the "absolute"

so |x| is to be read "absolute of x"

What do absolute do? it force the number to be positive!

if x is positive, keep it positive
if x is below zero (negative), change the sign to make x positive.

Why we use absolute?

As I explained before, some numbers cannot be represented by Softimage like those that are imaginary (sqrt(-x))!
By making the number always positive, we make sure Softimage is able to calculate the number and put a corresponding point on the screen.

For example, In Thiago formula

|cos(x) + cos(z)| ^ (1/2)

He is asking to do the square root of the sum of two cosines. As cosines varies from positive numbers to negative numbers, if we do not force the result to remain positive with the "absolute node", we would be dealing with a lot of imaginary numbers which could not be represented by Softimage.

the square root of the absolute of cos(x)+cos(z) convert imaginary numbers to numbers that can be represented.

Keep the absolute node in mind when playing with formulas. This is one weapon to remember.

Below is Thiago formula |cos(x) + cos(z)| ^ (1/2) in Parametric Sandbox ICE representation!
Attachments
Grid_Cosine_Pillow.jpg
Grid_Cosine_Pillow.jpg (123.62 KiB) Viewed 4594 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 03 Jan 2012, 23:04

Division by Zero and Overflow

When working with parameters, you will often encounter formulas that will not display on screen or simply crash Softimage. This is often caused by the “Division by Zero”.

An attempt to divide by zero may, depending on the situation and type of number being divided by zero, generate an exception, generate an error message, crash Softimage, generate either positive or negative infinity, or result in a Not-a-Number (NaN) value.

A common solution to this problem is to test the divisor (lower portion of the fraction) and the dividend (upper portion of the fraction) to avoid division by zero condition.

With ICE, we can use some if nodes to test these conditions:

Let’s “a” be the dividend, “b” the divider and “e” a small threshold value of our choice called epsilon so that:
a / b = c (quotient or result)

Test Condition, b = 0

Case a/0
The case a/0 will result in a NaN or undefined condition. Too many of them and Softimage will crash! In order to avoid this situation, we need to clamp “b” to a very small value and not assign zero to “b”. We do this by testing “b” and comparing it to the very small value epsilon (e). If “b” is lower than epsilon, we then force it to equal epsilon.

Now “b” can be negative or positive. If we test “–b” less than epsilon, the condition will be true. We clearly don’t want that. The solution is to use an “absolute” node on “b”, before testing, so that the condition is true only when “b” is between –epsilon < b < epsilon. Make sure if negative b your set epsilon is also negative.

Test Condition, a = 0

If “a” equal to zero then we end up with two problems:

0/0 case and
0/b case, where b is not equal to zero.

In the case 0/b we clearly want to avoid an expensive division. We know already that the result will be zero anyway. We test “a” equal to zero and if true force the result “c” to equal zero, avoiding the division altogether. If “a” does not equal to zero, then we do the division with “b”.

But then we could end up with a/0 condition?

This is when the order of the “if” will become important.

What if we have the 0/0 case?

Again, it all comes to testing in the right order. What is the order then?
Test “b” first, because we are clamping “b” to a small value or our choice (epsilon) other than zero, it become impossible for the case 0/0 to happen at the second “if” test! The trick is to choose epsilon small enough for Softimage not to assume the value is zero.

---------------------------------------------------------------------
Overflow

There is still a subject we have not touch yet …. The overflow!

Overflow is when the value of the result is so large that we get an error from Softimage. Here again we need to clamp the value to avoid this condition.

This condition can happen when “a” is too large or b is too small which will result in a huge number when divided that cannot be represented by Softimage.

To avoid this, we need to test if “absolute of a” is larger than a set upper limit (we don’t need to test b, b will never be lower than epsilon at this point!). if yes, we will set “a” to a value large enough that we know will not throw an error when divided by epsilon. Don’t forget to test and carry the sign of "a" to the set value!

Finally, do the division.

-----------------------------------------------------------------------

Other cases

There are still cases where errors can occur:

If “a and/or “b” are invalid, then we will have an error. We can test “a” and “b” prior doing all of this and throw an error is they are invalid.

What if “b” is huge and “a” is small? Then Softimage will make the result near or equal to zero! We can leave with that!

There are always risks doing parametric equation experimentation. We can’t avoid them but we can be smart when doing testing to avoid some obvious pitfalls.

Cheers!
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 05 Jan 2012, 04:14

Deep_Well

To illustrate the division by zero issue, I will use one of Thiago Costa formulas as an example. The Formula is

-1 / (x^2 + z^2)

The parametric form of this surface is:

x = f(u,v) = u
y = g(u,v) = -1 / (u*u + v*v)
z = h(u,v) = v

with

u_start = -10
u_end = 10
v_start = -10
v_end = 10

If you put the equation as per the ICE tree below (deep_well1) you will notice nothing on screen. The reason is simple: when u and v equal zero, we get a "division by zero" which throw an error in the formula.

If we look at the divisor (u*u + v*v) we notice that, to avoid the "division by zero", there are several strategies to avoid the problem.

-------------------------------

Strategy number 1

Make sure u or v does not reach zero so that the divisor equation u*u + v*v result in a number different than zero.

We do that by adjusting one of the parameters so that zero cannot be reached.

In figure Deep_well2, I adjusted u_start to be small but not zero.

Unfortunately we only get half of the surface. To get the entire surface I would have to create the other half of the surface and merge them together.

------------------------

Strategy number 2

We add a small amount to the divisor so that, when u and v reach zero, their is no chance to get the division by zero problem because of the added value.

Like so: a + (u*u + v*v)

This work because (u*u + v*v) is always a positive number. (Try it)

In figure deep_well3, I am showing the ICE tree and result. Now we can adjust the parameters to get a full surface.

Be aware that this startegy would not work if the formula was (u^3 + v^3) because there is a chance to get a number exactly the negative of the amount we are adding, creating the division by zero.

example 2 + ( (-1*-1*-1) + (-1*-1*-1)) = 0
Attachments
Deep_well1.jpg
Deep_well1.jpg (70.33 KiB) Viewed 4490 times
Deep_well2.jpg
Deep_well2.jpg (66.36 KiB) Viewed 4490 times
Deep_well3.jpg
Deep_well3.jpg (109.1 KiB) Viewed 4490 times
Last edited by Daniel Brassard on 05 Jan 2012, 05:21, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 05 Jan 2012, 04:46

Startegy number 3

Test the divisor and clamp it to a small value of our choice (tolerance) when it reach near zero.

Figure deep_well4 provides the ice tree for this strategy.

Notice the compound node that test the divisor. The compound purpose is only to test if the divisor is near or equal to zero. Refer to the "division by zero and overflow" post earlier for a more detailed explaination.

In this startegy, we clamp the value of the divisor to the tolerance so that the divisor never reach zero.

Figure deep_well5 provides the inside of the divisor_test compound.

Notice that, for both "if" nodes, i changed the epsilon value to zero because the tolerance value provides the clamping factor to the surface, therefore we don't need an epsilon range for the test.

The tolerance was set to a very small amount.

Figure deep_well6 shows the result of the compound with different parameters to illustrate the versatility of this method.

You may have notice by now that I did not test the upper number of the fraction (divident). As the divident is a constant (-1), I don't need to test it. But if you are modifying the compound like the last figure so that you can modify the weight of the well, make sure you don't feed the formula with a number so large that Softimage will throw an error (overflow).

Hope this example help you understand the "division by zero" problem and provided you with some tools to cope with this problem.

Cheers!
Attachments
Deep_well4.jpg
Deep_well4.jpg (110.75 KiB) Viewed 4482 times
Deep_well5.jpg
Deep_well5.jpg (70.63 KiB) Viewed 4482 times
Deep_well6.jpg
Deep_well6.jpg (40.59 KiB) Viewed 4483 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 05 Jan 2012, 05:04

And here is the divisor_test compound.

Enjoy!
Attachments
Divisor_test.xsicompound
(9.28 KiB) Downloaded 191 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

Ramon
Posts: 111
Joined: 19 Aug 2010, 22:47

Re: ICE Topology and parametric equations

Post by Ramon » 05 Jan 2012, 08:25

gr8

User avatar
ActionArt
Posts: 853
Joined: 25 Nov 2010, 18:23
Location: Canada

Re: ICE Topology and parametric equations

Post by ActionArt » 05 Jan 2012, 12:05

Wow, you're really flying Daniel. I'm trying to keep up. You could put this into a book someday! Very enjoyable.

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 08 Jan 2012, 21:19

Thank you Ramon and ActionArt for your kind word. I hope you are enjoying the adventure!
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 08 Jan 2012, 21:22

I will now be leaving Thiago formulas behind and let you, the readers, explore them further.

In order to keep the formula short, I will keep from repeating f(u,v), g(u,v) and h(u,v).
Just remember they are u and v equations associated with the x, y and z parameters!

Moving along to variations of the disk!
Last edited by Daniel Brassard on 09 Jan 2012, 02:48, edited 4 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 08 Jan 2012, 21:41

Disk Variations

If you remember the disk formula, it was:

x = v * sin(u)
y = 0
z = v * cos(u)

We already seen a variation of the disk with the cone, where we fed y with v.

x = v * sin(u)
y = v
z = v * cos(u)

But what else can we do with the disk? How about the square of v, what do we get?

The Paraboloid

x = v * sin(u)
y = v * v
z = v * cos(u)

u_start = 0
u_end = 2*PI .......... if you have not figured it out yet, 2*PI is the radian equivalent of 360 degrees!
v_start = 0
v_end = 1

Below is the Paraboloid ICE Tree and result!
Attachments
Paraboloid.jpg
Paraboloid.jpg (59.06 KiB) Viewed 3333 times
Paraboloid2.jpg
Paraboloid2.jpg (80.87 KiB) Viewed 3333 times
Last edited by Daniel Brassard on 09 Jan 2012, 02:49, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: ICE Topology and parametric equations

Post by Daniel Brassard » 08 Jan 2012, 22:20

Disk Helicoid

This simple form can been seen has rotating and moving up (or down) the disk around the y axis. We use a height value to displace the disk up during the rotation, creating the helix. The u parameter is fed to the three components to create the helix.

The parameters of the Helicoid are:

x = v * sin(u)
y = height * u
z = v * cos(u)

where

u_start = 0
u_end = 4*PI (you can do as many rotation as you wish, even animate it)
v_start = 0
v_end = 3
height = .1

The helicoid ICE tree and result is as follow. Notice that in the last figure (Helicoid3), we changed some parameter's values to get a ramp like shape.
Attachments
Helicoid.jpg
Helicoid.jpg (64.58 KiB) Viewed 3328 times
Helicoid2.jpg
Helicoid2.jpg (73.21 KiB) Viewed 3329 times
Helicoid3.jpg
Helicoid3.jpg (44.32 KiB) Viewed 3329 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests