Hi Alan, seems like your answer was on right on the
spot.
but on kims suggestion I found back the thread on
xsibase:
I got it working with Rafaelle's method, that
doesnt involve dot product, nor inverse cosine.
just cross product, normalize and putting it into a
matrix that goes straight to an object's transform.
on the bottom of the page there is a method by
Andrea, that is pretty much exactly what you
suggested.
this uses the inverse cosine of the dot
product and so on:
...
var angle = Math.acos(upVec.dot(polyNormal));
...
cant find one in vbscript though.
what I did come up with is
where inverse cosine is made up like
this:
Arccos(X) = Atn(-X / Sqr(-X * X + 1))
+ 2 * Atn(1)
microsoft helps to keep things simple
:-)
if anyone knows of an inverse cosine function in
vbscript, I'd love to know.
peter
Excuse my laziness I didn't real through all your code so I've no idea
how you're tackling this, but here's a simple approach I'd recommend anyway
(I'll explain the math rather than coding it out.)
Take the direction
you want to be "up" on your object (probably the y axis I guess so 0,1,0). Get
the cross product of that with the normal you want it to rotate to. The result
is the axis you want to rotate your object around. To get the angle you want
to rotate your object get the dot product of the up axis and the normal. Then
get the inverse cosine of this and that will be the angle in radians you want
to rotate it. The only problem you'll probably come into this way is defining
how it rotates around the normal. You may want to look at doing this with a
direction vector which could be global or using the U and V directions or
whatever.
Cheers,