Help me understand the "w" component of a Vector4

   13393   2   1
User Avatar
Member
45 posts
Joined: March 2010
Offline
…please!

I've been really struggling to understand what that whole “w” thing means, and I could really use some guidance. I've done a fair amount of internet-investigating, and I'm still having a little bit of trouble actually piecing it all together. So, if anyone has any resources or examples that can help me understand what's happening, I'd really appreciate it.

Please forgive the scattered nature of this post… there's a lot I'm not quite understanding.

Specifically, my cousin is trying to write an OpenGL raytracer, and he's having trouble understanding how raytrace a cube; the example given to him in class involves negative ones as the fourth term in a vector4, and it's confusing him. I offered to help, since Houdini has time and time again proven to be an invaluable tool for understanding all sorts of stuff, but… I'm kind of stuck here.

Here's what I've discovered:
- In Houdini, you can of course use a vector4 to arbitrarily hold data (eg, RGBA values). So that's cool.
- When talking about homogeneous coordinates (which is its own mindf*ck for me), the fourth component denotes whether a vector4 represents a point (1? not-zero?) or a vector (0); and we like using 4x4 matrices for our transformations because they can represent rotation, scale, translation, and shear all at once, in some order, yes?
- So, it should be possible to represent a cartesian point with homogenous coordinates . If “w” is zero, the vector is said to exist at “infinity” - which, for all intents and purposes, just means it represents a direction. And if “w” is less than one, the distance from the projection origin elongates; and shortens if w is greater than 1. Is that right? Thusfar, I haven't seen any introductory examples that use a value other than 1 or 0, but it's possible I haven't ventured far enough to see that kind of stuff. I understand that the “w” value must be either zero or one for use with a matrix4, right?
- That said, it seems that using a vector4 is sometimes nothing more than a convenient way to integrate matrix4s.
- Okay. And then we have the Add SOP, which lets you specify a W component between 0 and 1000 by default. I don't… fully understand what that's about, or how it can be used. There are a lot of examples for the Add SOP, but I didn't really see much that seemed to address this “W” term.
- And can't the “w” term be used to denote orientation or angular velocity? I feel like I've definitely seen that coming out of POPs. Is that just another use of a vector4 type to represent a quaternion, or… something else?
- So, back to my cousin's problem - what the hell does it mean if the “w” term in a vector4 is negative one? Does that just flip the handedness of the world or something? It seems like it would refer to coordinates behind the camera.

Any elucidation would be appreciated!
User Avatar
Member
45 posts
Joined: March 2010
Offline
Okay, no biters… that's understandable, this is a little all-over-the-place. My impression is that “w” means different things in different contexts. It's probably not too fruitful to ask about GLSL in the “Learning Houdini” forum

As for the “w” parameter on an Add SOP… I don't know how I missed this since it's in the friggin' help card, which is the first place I check pretty much always, but that“w” parameter can be used as a “weight” if the points generated by the Add SOP are used to connect a Bezier or NURBS curve. Embarrassing.

As for angular velocity, I was confusing myself. There is a float vector named “w” generated by things like the Angular Velocity POP that represents… angular velocity. That makes much more sense to me than having something like angular velocity represented by a single float at the end of a vector4, unless that value was just being stored there, to be later used to rotate a vector that many radians or degrees about an axis to be determined later. I guess that would be a valid but kind of a strange thing to do.

So - in summary - the Add SOP creates a vector4, with the last component (P.w) only relevant in the context of weighting a point (a knot?) on non-polygonal curves; and the angular velocity representation I was referring to has nothing to do, really, with a P.w vector4 component, and everything to do with a standard vector3 named “w”.

And then, indeed, I could store orientation represented as a quaternion in a vector4 named “orient,” which is automatically applied, if present, to instanced and copied points, I think prior to any other explicit transformations. But if I'm not mistaken, the vector4 components of a quaternion only make sense in relation to each other; its closest analog to cartesian transformations is the matrix3 that represents the same rotation.

(Quaternions are weird and mystical, by the way - I love that Houdini lets me sling them around to the effect of being able to rotate an angle about an axis, without fully having to understand how three sets of imaginary numbers mutually affect each other - but I hope to acquire that understanding some day).



As for using vector4s to store homogeneous coordinates… well… there's still a lot I don't understand about projection spaces. But it seems less relevant to the use of Houdini, at least in terms of surface operations. Although I imagine an understanding of such things must be useful in terms of camera frustum culling, or projecting UVs, that type of thing.

In case anyone else is confused by homogeneous coordinates, etc, here are a few resources that I'm currently trying to digest that seem useful:
User Avatar
Member
68 posts
Joined: May 2013
Offline
The only thing I can add at this time is it seems at times when doing the math of it, it's used more as a bounds or axis and not really something to mess with.
For reference my limited exposure is that I've used a reduced row echelon matrices transformation to calculate a true collision between vectors before (for html5 actually).
http://www.youtube.com/watch?v=-aAucWVD–M [youtube.com]
Not knowing much about it, but I can get the solution when it is needed. So to think about the problem and not so much the logic of how to do it at times seems like a functional route (although I like to understand why, somethings you'll have to get back to later shall we say).
Since (in my example) two equations that define slopes are joined and reduced the result is where they meet, potentially, I think, or something like that.
Also note the way the numbers are run in this video…
http://www.youtube.com/watch?v=vJLGWpob0T8 [youtube.com]
So I'm saying I think sometimes you use extra rows of a quaternion just to stabilize the math and give it direction or an axis and bounds (for lack of a better word).
  • Quick Links