12 Sep 2008 @ 9:05 AM 
 

Freakin Maya Transform Matrices

 

Matrix math is a bitch. And it's nigh impossible to find any good resources online. Every "transform matrix tutorial" or "matrix multiplication lesson" online explains in detail how to multiply matrices together.

That hasn't been my problem for about 25 years now. I get it. This is how you multiply a matrix with a vector. This is how you multiply two matrices together. Neither of those things actually *accomplishes* anything if you don't know what the data in those matrices represents or what adding, subtracting or multiplying them would do.

My problems always center around something more like this: I have a point at <10,20,30> with orientation <15,30,45>. Where is the point if I rotate it 15 degrees in y then translate it 100 units in the X axis?

What's screwed up is that I've so frequently solved this by doing trig that I know off the top of my head that pi/180 is estimated at 57.29577951. Some people pride themselves on the number of digits they know pi to: I find the radian conversion number to be far more handy. But for reference, pi to me is 3.14159265. Note the 8 significant digits behind the decimal number: can you tell what decimal significance I grew up programming in?

The thing is, I'm working on a number of tools for managing stereo cameras in Maya. I need to quickly determine from the transforms of one camera (derived from a track of live footage) the location and orientation of a second camera if we know (or can estimate or otherwise determine) the interocular distance (the distance between the eyes) and the convergence (how far in front of these cameras their line of sight intersects). Determining the angle of the second camera relative to the first is a straightforward bit of trig: think Pythagoras and arctangents and it'll come to you, or go find a good trig reference online - this part's easily found in a million places. Diagram that out for yourself, making an equilateral triangle with cameras at each base corner with convergence being the length of a line bisecting the triangle into two right triangles. If it's not immediately clear, work on it a bit: it might wake up parts of your brain that haven't seen the light of day since highschool.

The tricky bit is figuring out where a right-eye camera would be if it was offset along a line that isn't quite perpendicular to the left-eye camera.

I'm very nearly there - based on a given camera, I can find a point offset along that camera's X axis and apply a convergence factor to the resulting camera location by canting it back in along the Y. But rotating a known transform matrix by an additional value in the y axis *before* doing that x translation... still fussing with that bit. I can make that happen less elegantly - by actually transforming nulls through space in Maya - but I'm searching for the magical transformation matrix that'll make it happen in a simple series of math statements.

It's late. It'll probably be plenty clear to me in the morning.

UPDATE: Got it! Sleep did wonders - my tired brain just didn't quite get the matrix arrangement right before.  I'll write an entry this weekend covering concatenated matrix transforms.  Damn handy.  Damn powerful.

Tags Tags: , , , , , , , , , , , , , , ,
Categories: Uncategorized, geektalk, mel scripting, visual effects, visual effects pipeline
Posted By: Eddie
E-mail | Permalink | Comments (0)
 17 Mar 2008 @ 1:34 AM 
 

This isn’t what “Everybody’s working for the weekend” is supposed to mean

 

but I ended up going in to work today anyway.

I'd agreed without thinking more than "yeah, extra cash would be nice" and forgot what had been looming.

Annoying project. I mean, the spot's going to look cool even if it's a little froufrou. But the details of making it happen are tedious and I agreed to come in and track which I haven't done much of recently and am starting to not miss at all.

So I went in, tracked, found out it wasn't *nearly* as annoying as I'd anticipated... and briefly wandered off into MEL scripting territory to make a button that places arbitrary geometry at the location and orientation of any locators or mesh vertices that you have selected as well as constraining the new geo to the locators in case they were animated. I may change it to orient based on the vertex normal. That might be more handy. It was irrelevant for this purpose though.

That's more interesting and is more helpful for everyone else.

Besides that, I've a thought in my head: My WordPress blog, while inherently "personal" is more along the professional side. Same with my facebook profile... A sizable chunk of my facebook friends are people I know professionally: so glittery graphic "thanks for the add!" and stupid pictures get deleted from my wall. casual banter is fine: but things I wouldn't do or say at work don't happen there either. I've started deleting comments that wouldn't be appropriate to yell out at me at work. If you leave a comment that gets deleted: I'm not mad at you, I'm just not going to embarrass myself on anyone else's behalf.

Myspace is a filthy pit anyway, so I'm not policing it yet. Professional contacts on there are incidental, but I'm probably going to clean that mess up soon as well.

Tags Tags: , , , , , , , , , , , , , , , , ,
Categories: Uncategorized, kvetching, mel scripting, personal
Posted By: Eddie
E-mail | Permalink | Comments (0)
\/ More Options ...
Not Logged In.
  • Role »
  • Posts »
  • Comments »
Change Theme...
  • VoidVoid (Default)
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LiteLightweight