Houdini attributes

   11653   13   4
User Avatar
Member
10 posts
Joined: Aug. 2017
Offline
Hi guys..!
I'm new to Houdini so can anyone can help me
with my problems,
I'm getting confused in
1) what is float ?
2) what is integer ?
3) what is vector ?
vfx
User Avatar
Member
603 posts
Joined: July 2013
Offline
  1. float is a number with a decimal portion
  2. integer is a whole number without a decimal portion
  3. vector is a structure comprised of 3 floats.
Houdini Indie
Karma/Redshift 3D
User Avatar
Member
74 posts
Joined: March 2016
Offline
I'd recommend you do the Algebra basics course on Khan Academy whilst learning Houdini. If only to refresh your mind on the stuff you learned at school.

Khan Academy Algebra Basics [www.khanacademy.org]

And this course on Vector Match for 3d artists is really helpful too.

Vector Math for 3d Artists [chortle.ccsu.edu]
Edited by Jonathan Moore2 - Aug. 9, 2017 11:50:34
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Expanding on Daryl Dunlap's nice quick response,

deadpool111
1) what is float ?
A “float” (or floating-point number) is any real number, but represented with finite precision (usually either 32 or 64 bits, though sometimes 16 bits). One thing to note about floats that surprises a lot of people is that many numbers that look simple in decimal, like 0.1, are not exactly that value when represented in floating-point, so you have to be careful when checking whether two float values are equal, to instead check if they're approximately equal. You might have to be careful about accumulating roundoff error in some cases, too.

deadpool111
2) what is integer ?
An integer is a counting number or the negative of one, so …, -3, -2, -1, 0, 1, 2, 3, … They are usually either 32 or 64 bits, so their range is limited, but that's usually not a big issue.

deadpool111
3) what is vector ?
In Houdini, a vector is 3 floats, usually representing values corresponding with x, y, and z, though there are often vectors whose values correspond with red, green, and blue colour components. It's all up to how the values are used.

One additional meaning of vector in Houdini is a little closer to a more mathematical view of vectors, namely a direction and magnitude: attributes that are marked as transforming like a vector, (you can set this in the Attribute Create SOP with the second drop-down next to Type), will be rotated and scaled, but not translated, when they're transformed. The velocity attribute, named v, is normally set to transform like a vector (noted by Vec in the middle-mouse-button dialog), whereas Pis set to transform like positions (rotated, scaled, and translated; Pos in the middle-mouse-button dialog), Nis set to transform like normals (rotated and inverse-scaled, then normalized; Nml in the middle-mouse-button dialog). Most other 3-float attributes, by default, are not transformed when transformations occur.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
ndickson
One thing to note about floats that surprises a lot of people is that many numbers that look simple in decimal, like 0.1, are not exactly that value when represented in floating-point

to add the what Neil said,
sometimes a parameter will have a value like this: 1.77636e-15
this is zero (0) in float
you can safely make these 0 manually.
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
10 posts
Joined: Aug. 2017
Offline
thank you guys for replying,it was very helpful…
Edited by deadpool111 - Aug. 12, 2017 01:36:55
vfx
User Avatar
Member
38 posts
Joined: June 2015
Offline
goldfarb
ndickson
One thing to note about floats that surprises a lot of people is that many numbers that look simple in decimal, like 0.1, are not exactly that value when represented in floating-point

to add the what Neil said,
sometimes a parameter will have a value like this: 1.77636e-15
this is zero (0) in float
you can safely make these 0 manually.

how?
User Avatar
Member
7740 posts
Joined: Sept. 2011
Offline
I'm not sure what @goldfarb meant. Maybe he meant that the values are small enough that they are zero for all intents and purposes.

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
goldfarb
ndickson
One thing to note about floats that surprises a lot of people is that many numbers that look simple in decimal, like 0.1, are not exactly that value when represented in floating-point

to add the what Neil said,
sometimes a parameter will have a value like this: 1.77636e-15
this is zero (0) in float
you can safely make these 0 manually.


let's pretend that that “weird” number is a value of point attribute @P.y

I then add a vex wrangle with the following ‘if statement’:
if (@P.y == 0) {removepoint(0, @ptnum);}

will the point with that weird number be removed?
Edited by Andr - Oct. 4, 2018 04:51:52
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Talking about working with vectors, I noticed this strange thing:

Add a wrangle with:
v@myVector = set(1,2,3);
@N = @myVector; // @N is set correctly to (1,2,3). @N and @myVector are created in the same context (same wrangle)

Now add another wrangle to the one just created and re-assign @N to @myVector:
@N = @myVector; // @N is set now to (1,1,1) !! Only the first component is read.

Is Houdini no more aware that @myVector is a vector?
To fix that, you have to specify that it is a vector. @N = v@myVector; works indeed.


That took me a lot of time to figure out the first time, when I was going crazy with not being able to assign any vector attribute to N.

Is this a bug or is there any deeper reason on how Houdini works behind the scene that would explain this behavior?


I attached an example file
Cheers

Attachments:
Q_vectorAssignement.hiplc (49.1 KB)

User Avatar
Member
61 posts
Joined: April 2018
Offline
Andr
let's pretend that that “weird” number is a value of point attribute @P.y

I then add a vex wrangle with the following ‘if statement’:
if (@P.y == 0) {removepoint(0, @ptnum);}

will the point with that weird number be removed?
In this case, no. Generally, float comparisons can behave unintuitively because of rounding errors. The following approach is a reasonable solution for many cases, and will indeed work as expected in your example, by testing if the value is acceptably near zero:

#define EPSILON 1e-8
if (abs(@P.y) < EPSILON) { removepoint(0, @ptnum); }

<math.h> also defines TOLERANCE to be 0.0001, which I guess may be being used in a similar way.

For more on this topic, this site [floating-point-gui.de] has very useful information.
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Andr
Add a wrangle with:
v@myVector = set(1,2,3);
@N = @myVector; // @N is set correctly to (1,2,3). @N and @myVector are created in the same context (same wrangle)

Now add another wrangle to the one just created and re-assign @N to @myVector:
@N = @myVector; // @N is set now to (1,1,1) !! Only the first component is read.

Is Houdini no more aware that @myVector is a vector?
To fix that, you have to specify that it is a vector. @N = v@myVector; works indeed.
By default, if it's not specified in at least one place in the wrangle with a prefix or an explicit declaration like vector @myVector;Attribute Wrangle's VEX code will assume that attributes are single float values, except for a few hardcoded ones with different default assumptions, (for example, @P, @N, @v, @Cd, @up,will be assumed to be vector, @idwill be assumed to be an integer, and @orientwill be assumed to be a vector4, among others.) If you're not sure, it's always best to be on the safe side.

The reason that it can't just dynamically figure out attribute types as they come in is a bit technical, but in a nutshell, the VEX code needs to know what types it's dealing with before it actually receives any input data. When it eventually gets input data, if the types mismatch, it needs to convert to whatever type VEX already chose. In concept, it could recompile the VEX code if there are mismatched bindings, but that would be quite complicated to manage internally and would have behavioural/compatibility consequences that might not always be what people expect.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline

let's pretend that that “weird” number is a value of point attribute @P.y

if (@P.y == 0) {removepoint(0, @ptnum);}

One way to do deal with it is to think about the context then adjust your logic of the code. In other words, how did this number come close to 0 but isn't quite there.

The question would be, do you need it at 0 or is it something that you want that might be close to 0.

Your code could deal with it a number of ways, depending on what you want(the below examples not neccesarily giving the same results):

if (@P.y == 0) {removepoint(0, @ptnum);}

or

if (@P.y >= 0) {removepoint(0, @ptnum);}

or

if (@P.y >= 0) {removepoint(0, @ptnum);}

or

if( (@P.y !> 0) && (@P.y !< 0) ) {removepoint(0, @ptnum);}
Edited by BabaJ - Oct. 4, 2018 13:22:06
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
forgot to say thanks to you all guys for the explaining and advising!

cheers
  • Quick Links