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 ?
Houdini attributes
9456 13 4-
- deadpool111
- Member
- 10 posts
- Joined: Aug. 2017
- Offline
-
- TwinSnakes007
- Member
- 408 posts
- Joined: July 2013
- Offline
-
- Jonathan Moore2
- 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]
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
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
Expanding on Daryl Dunlap's nice quick response,
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
deadpool111A “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.
1) what is float ?
deadpool111An 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.
2) what is integer ?
deadpool111In 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.
3) what is vector ?
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 P
is set to transform like positions (rotated, scaled, and translated; Pos in the middle-mouse-button dialog), N
is 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]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- goldfarb
- Staff
- 3452 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.
-
- deadpool111
- Member
- 10 posts
- Joined: Aug. 2017
- Offline
-
- adamalbo
- Member
- 29 posts
- Joined: June 2015
- Offline
goldfarbndickson
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?
-
- jsmack
- Member
- 6790 posts
- Joined: Sept. 2011
- Offline
-
- Andr
- Member
- 838 posts
- Joined: Feb. 2016
- Offline
goldfarbndickson
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
-
- Andr
- Member
- 838 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
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
-
- pabcou
- Member
- 59 posts
- Joined: April 2018
- Offline
AndrIn 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:
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?
#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.
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
AndrBy default, if it's not specified in at least one place in the wrangle with a prefix or an explicit declaration like
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.
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, @id
will be assumed to be an integer, and @orient
will 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]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- BabaJ
- Member
- 1944 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
-
- Andr
- Member
- 838 posts
- Joined: Feb. 2016
- Offline
-
- Quick Links