Difference between vector and 3 float

   23154   16   6
User Avatar
Member
20 posts
Joined: 9月 2010
Offline
Hi guys,

I understand this question is sort of basic. I tried to find related info on this site or internet but I can't. Is anyone can give me some hint? Thanks!
User Avatar
Member
1909 posts
Joined: 11月 2006
Offline
On the surface they behave similar but there is a subtle difference. A vector and 3 floats both store the same information, but a vector attribute can be transformed. For example, if you create an attribute that is 3 floats and assign some values, then use a Transform SOP to rotate your geometry the values remain constant. However, if you change the type to Vector you will notice that the values are transformed as a vector as you rotate the geometry. The advantage of this is that you can have vector attributes that are properly transformed as your geometry changes so your vectors are always consistent with the modified geometry. If you just want to store a triple of values you can use 3 floats.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
スタッフ
2540 posts
Joined: 7月 2005
Offline
I do believe a 3 float vector like P for position can be transformed but everything else Graham stated is quite correct.

Generally 3 float vector attributes are used to store position data like “P”, “uv” and “rest”. It is also used to store any arbitrary three values per point like “Color” and “scale” (used in instancing). It makes sense to translate “P”, “uv” and “rest” while you don't want to translate “Color” and “scale” where other operations are valid/common.

vector3 attributes are used to hold vector data such as “N” normals, “v” velocity and for storing the result of subtracting two 3 float vector Point positions used all the time to get direction (XYZ values) and magnitude (length of the vector).

As Graham stated, you want to transform 3 float vector data differently than vector3 data. Both take transforms differently. 3 float vector data is actually moved in space with a Transform. vector3 data is transformed along the points to keep their orientation wrt the transform rotation and scale.

One exception to transforming vector3 data is point surface Normals “N”. They require a different transform. Thankfully “N” attributes by default are transformed this way by SOPs that deform geometry.
There's at least one school like the old school!
User Avatar
Member
31 posts
Joined: 5月 2007
Offline
Hi kzchen,

Peter Quint Houdini Tutorial on Vimeo

Basics : Attributes III
http://vimeo.com/channels/54102#6803939 [vimeo.com]
User Avatar
Member
20 posts
Joined: 9月 2010
Offline
Hi Jeff,

I really appreciate for your detailed explanation. It's helpful for me and I am digesting it!


Hi Acaiborka,

Thanks for sharing this video. I will check it out!
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
3 float vector is also what you want to use for a rest position attribute. IF you selected vector all your values would change !

Rob
Gone fishing
User Avatar
Member
1743 posts
Joined: 3月 2012
Offline
Let's take a step back. Suppose that you have an attribute that is 3 floats. You might or might not want the attribute to get transformed by SOPs like Transform, Transform Axis, Soft Transform, Copy, Object Merge, etc, but there are different ways that such an attribute might be transformed, depending on what it is.

Using Attribute Create, if you put the attribute name in the “Name” field, and click the second drop-down over from the “Type” label, you'll see a bunch of options. You can use this to change the transform type. The ones that are relevant for 3-float attributes are:

* None: Doesn't transform at all. This is useful for attributes that either aren't positions, vectors, or normals, or that you just don't want to transform, like “rest”. The attribute will have “3f” in the middle-mouse menu.
* Position: Responds to translations, rotations, and scales, acting as if it's a point position. The attribute will have “3fp” in the middle-mouse menu.
* Vector: Responds to rotations and scales, acting as if it's a velocity. The attribute will have “3fv” in the middle-mouse menu.
* Normal: Responds to rotations and non-uniform scales, acting as if it's a normal vector on a surface. (e.g. Normals don't change under uniform scaling, and they change “opposite” from the way vectors do under non-uniform scaling.) The attribute will have “3fn” in the middle-mouse menu.
* Color: Doesn't transform at all. This doesn't really get used for much, functionality-wise. The attribute will have “3fc” in the middle-mouse menu.

If you have a 4-float attribute that you want to transform as quaternions, you can choose Quaternion (“4fq”), and if you have a 9-float or 16-float attribute that you want to transform as a 3x3 or 4x4 matrix, you can choose Transform Matrix (“9fx” or “16fx”). I'm not sure what'll happen for other combinations.

Hopefully that helps clear things up a bit.
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
379 posts
Joined: 12月 2006
Offline
Sometimes bots do good
User Avatar
Member
4189 posts
Joined: 6月 2012
Offline
Neil's description kicks butt over what is in the documentation. Add some .gif animations with Scene Visualisers and it would be killer!
User Avatar
Member
1743 posts
Joined: 3月 2012
Offline
MartybNz
Neil's description kicks butt over what is in the documentation.
The Attribute Create page has a little bit about it, and the Transform page says to use Attribute Create to set the transformation type, but the clarity could probably be improved. I'm not sure where a good generic page would be for it, but someone who works on the docs was asking me about this stuff just a few days ago, which is why it was fresh in my mind, so they probably have some idea.

Add some .gif animations with Scene Visualisers and it would be killer!
That'd be cool. Pro tip: the “Axes” visualizer type works with quaternions, which makes it sooooo much easier to work with quaternion attributes. :wink:
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
1747 posts
Joined: 5月 2006
Online
agreed! discovered that the other day when writing up some notes on rotation, its the bees knees (and when combined with animated gifs, hooooo-mama)

http://www.tokeru.com/cgwiki/index.php?title=HoudiniVex#More_on_rotation:_Orient.2C_Quaternions.2C_Matricies.2C_Offsets.2C_stuff [tokeru.com]
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
2624 posts
Joined: 8月 2006
Offline
Great reading and gifs

Rob
Gone fishing
User Avatar
Member
1743 posts
Joined: 3月 2012
Offline
@mestela: Cool!

Note that sample_sphere_uniform will sample uniformly from vectors *inside* the unit sphere, whereas sample_direction_uniform will sample uniformly from vectors on the surface of a unit sphere, i.e. unit vectors a.k.a. direction vectors. The code that figures out the transformation to do should normalize the vectors, so it should be okay either way, but sample_direction_uniform is a little faster. You can also get uniform random orientation quaternions using sample_orientation_uniform, or uniform within some angle of a base orientation using sample_orientation_cone.
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
1747 posts
Joined: 5月 2006
Online
Good to know, thanks!

My beef with all those functions though is that they're too damn long to type. I hate to bring up the M word here, but Maya's ‘sphrand’ is short, easy to remember, handy. Autocomplete is good n all, but sphrand just flows across the keyboard like warm butter. Cmon, type it with me…

…sphrand……. sphrand….



-matt
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
1743 posts
Joined: 3月 2012
Offline
Thanks to pusat for reporting that Attribute Create wasn't letting 9-float attributes be marked as transforming as a Transform Matrix! This should be fixed in tomorrow's build of Houdini 15.5, and if anyone needs it in 15.0, let me know, 'cause it should be easy to backport the fix. (Hopefully nobody is unknowingly relying on it not working.)
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
4540 posts
Joined: 2月 2012
Offline
Thanks to Neil for slaying this bug

This is uncommon in this industry to have this kind of legendary team that stands behind their product who are very proactive in fixing any issues that show up.
Edited by animatrix_ - 2016年7月13日 16:27:27
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
339 posts
Joined: 6月 2013
Online
ndickson
* Position: Responds to translations, rotations, and scales, acting as if it's a point position. The attribute will have “3fp” in the middle-mouse menu.
* Vector: Responds to rotations and scales, acting as if it's a velocity. The attribute will have “3fv” in the middle-mouse menu.

Hi, sorry for the necro-posting I just wanted to add to this information:
Position sub-type of Float type is sensible to what you put in the in Pivot input of a Transform SOP, while Vector sub-type doesn't care about it.
Vector type will behave the same in this regard as the homonym Float sub-type.

More over, any attribute created through Bind Export VOP or Set Attribute VOP will not be affected by a Transform SOP at all, since apparently one can't set those subtypes through those nodes!

Cheers
Edited by probiner - 2017年7月19日 23:54:19
  • Quick Links