tags:

views:

2591

answers:

2
+1  A: 

This should do you

Simon
This does not work, as I do not have angles; only the desired direction vector.
Edward Z. Yang
You can work out the angles using basic trig...SOH CAH TOAIf you don't know your basic trig you shouldn't be moneying around with vectors...
Simon
I know I can work the angles out, but that's extremely inefficient. It should be possible to figure out the matrix using only cross products.
Edward Z. Yang
If you can't spell 'monkeying' then you shouldn't be monkeying around with English.
House MD
+1  A: 

Dupe.

The question there involves getting a rotation to a certain axis, whereas I'm concerned with getting a rotation matrix.

Gee, I wonder if you could turn convert one to the other?

BTW, your current solution of picking an arbitrary y axis and then reorthogonalising should work fine; it looks bugged though, or at least badly written. 'z_vec' is not a good variable-name for the y-axis. What's with the 'z,x,y' ordering, anyway?

If it still doesn't work, try making random changes until it does - transpose the matrix, negate vectors until you have an even number of sign errors, that kind of thing.

Also your tone of voice comes across as sort-of rude, given that you're asking strangers to spend their time helping you.

House MD
The question there involves getting a rotation to a certain axis, whereas I'm concerned with getting a rotation matrix.
Edward Z. Yang
See my comments on the above answer. Yes, I could do that, but I'd like to get the above implementation working.
Edward Z. Yang
Sorry about that. I've been working for several hours on this, so I'm quite frustrated right now.
Edward Z. Yang
NP. I trust that randomly flipping vectors did the trick? Gotta love graphics programming...
House MD
Inverting and flipping the variable names did the trick. :-)
Edward Z. Yang