ICE Topology and parametric equations
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
The Torus second mapping.
Like the sphere, the torus has a second mapping as follows:
x = f(u,v) = Cos(u) * ( R0 + (R1 * Sin(v)))
y = g(u,v) = R1 * Cos(v)
z = h(u,v) = Sin(u) * (R0 + ( R1 * Sin(v)))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 2*PI
V_Start = 0
V_End - 2*PI
The ICE Tree and result is as below.
Like the sphere, the torus has a second mapping as follows:
x = f(u,v) = Cos(u) * ( R0 + (R1 * Sin(v)))
y = g(u,v) = R1 * Cos(v)
z = h(u,v) = Sin(u) * (R0 + ( R1 * Sin(v)))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 2*PI
V_Start = 0
V_End - 2*PI
The ICE Tree and result is as below.
- Attachments
-
- Torus3.jpg (71.08 KiB) Viewed 3649 times
-
- Torus4.jpg (86.42 KiB) Viewed 3649 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
Torus variations
Also like the sphere, we can modify the equations to control the height, width or depth by multiplying each equations with a scalar.
The torus equations are now:
x = f(u,v) = a * (Cos(u) * ( R0 + (R1 * Cos(v))))
y = g(u,v) = b * (R1 * Sin(v))
z = h(u,v) = c * (Sin(u) * (R0 + ( R1 * Cos(v))))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 2*PI
V_Start = 0
V_End - 2*PI
a, b and c are scalars to control the width, height and depth of the torus.
Below is a modification of the ICE tree in x,y and z with a stretch in height of the torus as an example.
Also like the sphere, we can modify the equations to control the height, width or depth by multiplying each equations with a scalar.
The torus equations are now:
x = f(u,v) = a * (Cos(u) * ( R0 + (R1 * Cos(v))))
y = g(u,v) = b * (R1 * Sin(v))
z = h(u,v) = c * (Sin(u) * (R0 + ( R1 * Cos(v))))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 2*PI
V_Start = 0
V_End - 2*PI
a, b and c are scalars to control the width, height and depth of the torus.
Below is a modification of the ICE tree in x,y and z with a stretch in height of the torus as an example.
- Attachments
-
- Torus5.jpg (77.33 KiB) Viewed 3648 times
-
- Torus6.jpg (84.49 KiB) Viewed 3648 times
Last edited by Daniel Brassard on 11 Dec 2011, 04:47, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
The Helical Torus
By adding a component to the y axis equation, we can change the torus to a spring type surface.
The equations are:
x = f(u,v) = Cos(u) * ( R0 + (R1 * Cos(v)))
y = g(u,v) = Stretch * u + (R1 * Sin(v)) (note the modification)
z = h(u,v) = Sin(u) * (R0 + ( R1 * Cos(v)))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 4*PI
V_Start = 0
V_End - 2*PI
Stretch = 1
The ICE Tree and result is as below.
By adding a component to the y axis equation, we can change the torus to a spring type surface.
The equations are:
x = f(u,v) = Cos(u) * ( R0 + (R1 * Cos(v)))
y = g(u,v) = Stretch * u + (R1 * Sin(v)) (note the modification)
z = h(u,v) = Sin(u) * (R0 + ( R1 * Cos(v)))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 4*PI
V_Start = 0
V_End - 2*PI
Stretch = 1
The ICE Tree and result is as below.
- Attachments
-
- Helical-Torus.jpg (72.62 KiB) Viewed 3647 times
-
- Helical-Torus2.jpg (79.66 KiB) Viewed 3647 times
Last edited by Daniel Brassard on 11 Dec 2011, 04:44, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
The Spiral Helical Torus (Shell)
An other of the Torus variation, this time we also control the size of the ring as its spiral around the y axis creating a Shell type surface.
The equations are:
x = f(u,v) = Cos(u) * ( R0 + (R1 * Cos(v)))
y = g(u,v) = u* (R1 * Sin(v)) - Stretch * u (note the modification)
z = h(u,v) = Sin(u) * (R0 + ( R1 * Cos(v)))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 4*PI
V_Start = 0
V_End - 2*PI
Stretch = 1.5
The ICE Tree and result is as below.
An other of the Torus variation, this time we also control the size of the ring as its spiral around the y axis creating a Shell type surface.
The equations are:
x = f(u,v) = Cos(u) * ( R0 + (R1 * Cos(v)))
y = g(u,v) = u* (R1 * Sin(v)) - Stretch * u (note the modification)
z = h(u,v) = Sin(u) * (R0 + ( R1 * Cos(v)))
where
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 4*PI
V_Start = 0
V_End - 2*PI
Stretch = 1.5
The ICE Tree and result is as below.
- Attachments
-
- Torus_Shell.jpg (76.68 KiB) Viewed 3645 times
-
- Torus_Shell2.jpg (82.86 KiB) Viewed 3645 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
The SuperTorus (Supertoroid)
Using the formulas provided by Paul Bourke on his website, we recreate the SuperTorus.
Basically, we are going to modify the torus by putting the cos and sin parateters in power of an exponent.
This will modify the surface in various ways based on the exponent chosen.
The supertorus equations are:
x = f(u,v) = exp(n1, Cos(u)) * ( R0 + ( R1 * exp(n2, Cos(v))))
y = g(u,v) = R1 * exp(n2, Sin(v))
z = h(u,v) = exp(n1, Sin(u)) * ( R0 + ( R1 * exp(n2, Cos(v))))
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 2*PI
V_Start = 0
V_End - 2*PI
n1 and n2 can adopt the values illustrated on the table from Paul Bourke website:
http://paulbourke.net/geometry/torus/
Here is the ICE tree and the result. Also attached is the SuperTorus compound for experimentation. Enjoy!
Using the formulas provided by Paul Bourke on his website, we recreate the SuperTorus.
Basically, we are going to modify the torus by putting the cos and sin parateters in power of an exponent.
This will modify the surface in various ways based on the exponent chosen.
The supertorus equations are:
x = f(u,v) = exp(n1, Cos(u)) * ( R0 + ( R1 * exp(n2, Cos(v))))
y = g(u,v) = R1 * exp(n2, Sin(v))
z = h(u,v) = exp(n1, Sin(u)) * ( R0 + ( R1 * exp(n2, Cos(v))))
R0 is the large radius = 1
R1 is the small radius = 0.25
U_start = 0
U_End = 2*PI
V_Start = 0
V_End - 2*PI
n1 and n2 can adopt the values illustrated on the table from Paul Bourke website:
http://paulbourke.net/geometry/torus/
Here is the ICE tree and the result. Also attached is the SuperTorus compound for experimentation. Enjoy!
- Attachments
-
- SuperTorus.xsicompound
- (126.05 KiB) Downloaded 146 times
-
- Super_Torus.jpg (74.96 KiB) Viewed 3610 times
-
- Super_Torus2.jpg (86.99 KiB) Viewed 3610 times
Last edited by Daniel Brassard on 10 Jan 2012, 18:25, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
A word of caution about Exponent
You will have to be carefull when experimeting with exponent. There are situation when the exponent will give you errors:
If the magnitude of the result is so large that it cannot be represented,
If the base is negative and the exponent is not an integer value, or
If the base is zero and the exponent is negative.
One example, is the square root of a negative number will result in an imaginary number.
http://www.mathsisfun.com/numbers/imagi ... mbers.html
Softimage will not be able to represent this number and will throw an error.
I have created a compound to convert imaginary numbers and to speed up calculation of zero or very small base so that they can be represented by Softimage. Attached is the compound. I have used this compound in the Supertorus and we will be using it again for other surfaces.
Cheers!
You will have to be carefull when experimeting with exponent. There are situation when the exponent will give you errors:
If the magnitude of the result is so large that it cannot be represented,
If the base is negative and the exponent is not an integer value, or
If the base is zero and the exponent is negative.
One example, is the square root of a negative number will result in an imaginary number.
http://www.mathsisfun.com/numbers/imagi ... mbers.html
Softimage will not be able to represent this number and will throw an error.
I have created a compound to convert imaginary numbers and to speed up calculation of zero or very small base so that they can be represented by Softimage. Attached is the compound. I have used this compound in the Supertorus and we will be using it again for other surfaces.
Cheers!
- Attachments
-
- Exponent_Converter.jpg (63.93 KiB) Viewed 3609 times
-
- Exponent_converter.xsicompound
- (10.97 KiB) Downloaded 137 times
Last edited by Daniel Brassard on 11 Dec 2011, 05:22, edited 2 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations (Warning math here!)
Well that is it for me tonight.
Before I go, here is the table of exponents for the Supertorus from Paul Bourke website as reference.
[edit] For those who are familiar with MODO, you may have recognised their torus implementation ... Enough said! ;)
Until next time, happy experimenting!
Before I go, here is the table of exponents for the Supertorus from Paul Bourke website as reference.
[edit] For those who are familiar with MODO, you may have recognised their torus implementation ... Enough said! ;)
Until next time, happy experimenting!
- Attachments
-
- supertoroid1.gif (82.29 KiB) Viewed 3606 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
Holes and Boundaries
You may have notice by now that the shapes created so far are open shapes for a good reason, we are twisting a flat grid. As an example, if you look at the cylinder, it is not capped or closed as indicated by the blue line in the middle, top and bottom of the shape.
There are many ways to close these shapes, depending on what your end result will be:
You can use the cap hole tool that come with 2012 SAP.
You can create your own capping tool using a variety of ICE nodes such as the merge vertices and collapse edge tool.
Me I prefer the old fation way, using tools already available in Softimage:
I merge vertices using the "Weld Boundary Point/Edges" with a very small distance threshold of .001
then
I select the edge loop of the hole I want to cap, duplicate the components (ctrl+D) than collapse the components (ctrl+delete)
or
I close boundaries using the "Bridge Boundary Point / Edges" operator.
That way I keep control of the final shape. Be aware that, with any techniques you use, make sure you get clean results and modify as needed. Check you shape in all angles, and correct if necessary.
You may have notice by now that the shapes created so far are open shapes for a good reason, we are twisting a flat grid. As an example, if you look at the cylinder, it is not capped or closed as indicated by the blue line in the middle, top and bottom of the shape.
There are many ways to close these shapes, depending on what your end result will be:
You can use the cap hole tool that come with 2012 SAP.
You can create your own capping tool using a variety of ICE nodes such as the merge vertices and collapse edge tool.
Me I prefer the old fation way, using tools already available in Softimage:
I merge vertices using the "Weld Boundary Point/Edges" with a very small distance threshold of .001
then
I select the edge loop of the hole I want to cap, duplicate the components (ctrl+D) than collapse the components (ctrl+delete)
or
I close boundaries using the "Bridge Boundary Point / Edges" operator.
That way I keep control of the final shape. Be aware that, with any techniques you use, make sure you get clean results and modify as needed. Check you shape in all angles, and correct if necessary.
- Attachments
-
- Cap_Hole_Boundary.jpg (57.96 KiB) Viewed 3478 times
-
- Cap_Hole_Boundary2.jpg (49.26 KiB) Viewed 3478 times
Last edited by Daniel Brassard on 01 Jan 2012, 03:08, edited 2 times in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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.
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
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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.
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 (61.28 KiB) Viewed 4772 times
-
- Radial_Wave2.jpg (116.63 KiB) Viewed 4772 times
Last edited by Daniel Brassard on 01 Jan 2012, 21:15, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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!
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!
- Attachments
-
- Saddle.jpg (53.74 KiB) Viewed 4766 times
-
- Saddle2.jpg (63.94 KiB) Viewed 4766 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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)
x^2 * z^2 (Grid_Elliptic_var1)
x^3 + z^3 (Grid_Elliptic_var2)
sin(x) (Grid_Sine_wave)
- Attachments
-
- Grid_Elliptic_var1.jpg (88.54 KiB) Viewed 4733 times
-
- Grid_Elliptic_var2.jpg (82.39 KiB) Viewed 4733 times
-
- Grid_Sine_wave.jpg (102.77 KiB) Viewed 4733 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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)
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 (82.34 KiB) Viewed 4732 times
-
- Grid_radial_wave2.jpg (94.76 KiB) Viewed 4732 times
-
- Grid_Radial_Wave3.jpg (95.06 KiB) Viewed 4732 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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!
|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 (123.62 KiB) Viewed 4730 times
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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!
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
set "Softimage" "true"
$endif
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: ICE Topology and parametric equations
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
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 (70.33 KiB) Viewed 4596 times
-
- Deep_well2.jpg (66.36 KiB) Viewed 4596 times
-
- Deep_well3.jpg (109.1 KiB) Viewed 4596 times
Last edited by Daniel Brassard on 05 Jan 2012, 05:21, edited 1 time in total.
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
Who is online
Users browsing this forum: No registered users and 72 guests