Im trying to better understand using expressions to drive parameters and I wondered if anyone could push me in the right direction.
I am just using a circle SOP and a line SOP. I would like to have the distance value of my line sop driven by the circumference of my circle. Now I understand the maths.
* The circumference of a circle can be found by multiplying pi ¶ (which is equal to 3.14) by the diameter of the circle.
* If a circle has a diameter of 4, its circumference is 3.14*4=12.56
* If you know the radius, the diameter is twice as large.
So this would mean I would need to create 2 expressions in the radius channels which would then be added together and then connected to the line distance value. The result would be a line that is the length of the circumference of my circle.This is where I become unstuck with knowing how to apply this anyone care to help ?
rob
expression help with Pi and more !
9660 6 2-
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
-
- edward
- Member
- 8081 posts
- Joined: July 2005
- Offline
-
- graham
- Member
- 1926 posts
- Joined: Nov. 2006
- Offline
This is also extremely easy in Houdini without even using expressions. If you append a Measure SOP to your circle, by default it will calculate the ‘perimeter’, or in this case the circumference. This results in a primitive attribute that can be looked up using the prim() function in the Line SOPs length.
This does have a downfall though. The perimeter will be affected by the type of primitive and the number of divisions your circle has. For example, a primitive circle, with radius 0.5 will have a perimeter of 2*Pi*r, 3.1416, according to Houdini, whereas if you change that to a Polygon sphere, with 10 divisions, the perimeter changes to 3.0917 because it is not perfectly round.
This does have a downfall though. The perimeter will be affected by the type of primitive and the number of divisions your circle has. For example, a primitive circle, with radius 0.5 will have a perimeter of 2*Pi*r, 3.1416, according to Houdini, whereas if you change that to a Polygon sphere, with 10 divisions, the perimeter changes to 3.0917 because it is not perfectly round.
Graham Thompson, Technical Artist @ Rockstar Games
-
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
Thankyou guys for the help. I notice you can appy maths functions to channel refs so can you apply maths functions like
ch(“/obj/geo1/revolve1/divs”) / ch(“../circle1/radx”)*2*$PI
to divide the one ref by another ?
update , Ive just done a test you can !!! Houdini is so elegant !
regards rob
ch(“/obj/geo1/revolve1/divs”) / ch(“../circle1/radx”)*2*$PI
to divide the one ref by another ?
update , Ive just done a test you can !!! Houdini is so elegant !
regards rob
Gone fishing
-
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
I have another expression question ! I am using a a copy sop operation and I am trying to create some random tapering width based on height . I found bits in the help which certainly went a way to helping me discover the width attribute !
I know the width Attr that I have added has a floating point value say in my case 0.3 . Now if I use fit01(rand$BBX), 0.001 , 0.009 ) I get random width across my lines clamped between 2 values but no taper.
So to add another layer I am wanting to add a random tapering value based on height and width.
I was thinking I could use the $BBY value would give be a height for any line being zero to one , a fit01 expression coupled with a rand() would give me random widths clamped between to values . I am just unsure how I could use the $BBY value to control my a taper .
Am I sort of heading in the right direction ?
regards Rob
I know the width Attr that I have added has a floating point value say in my case 0.3 . Now if I use fit01(rand$BBX), 0.001 , 0.009 ) I get random width across my lines clamped between 2 values but no taper.
So to add another layer I am wanting to add a random tapering value based on height and width.
I was thinking I could use the $BBY value would give be a height for any line being zero to one , a fit01 expression coupled with a rand() would give me random widths clamped between to values . I am just unsure how I could use the $BBY value to control my a taper .
Am I sort of heading in the right direction ?
regards Rob
Gone fishing
-
- keyframe
- Member
- 1533 posts
- Joined: July 2005
- Offline
Heya Rob,
$BBY is a constant for a given sop. You might look at using $TY instead to vary with by it's y-position.
Something I often do is create a “u” attribute along a curve by using:
fit($PT, 0, $NPT-1, 0, 1)
This creates an attribute on the range from your 0 point to the ‘last’ point. Then you can attribcreate a width attribute based on the ‘parametric’ length of a curve by using:
fit($U, 0, 1, 0.5, 0.02)
this varies the width attribute from the tip to the tail on .
You can also mess with various power functions (like squaring the width attribute for example) to mess with the shape of the taper in case you want something non-linear.
Hope this helps,
Gene
$BBY is a constant for a given sop. You might look at using $TY instead to vary with by it's y-position.
Something I often do is create a “u” attribute along a curve by using:
fit($PT, 0, $NPT-1, 0, 1)
This creates an attribute on the range from your 0 point to the ‘last’ point. Then you can attribcreate a width attribute based on the ‘parametric’ length of a curve by using:
fit($U, 0, 1, 0.5, 0.02)
this varies the width attribute from the tip to the tail on .
You can also mess with various power functions (like squaring the width attribute for example) to mess with the shape of the taper in case you want something non-linear.
Hope this helps,
Gene
-
- circusmonkey
- Member
- 2624 posts
- Joined: Aug. 2006
- Offline
-
- Quick Links
