So, This function doesn't work entirely well -- it works great
initially but the more you spin the object around, the more off it is.
I take this matrix, I apply it to my object, and then I add the last
rotationX/Y/Z .. this seems to be a poor approach; how could I use the
existing matrix in these calculations?

Also it seems to be rather complicated to calculate constantly... any
thoughts?

public static function
getArcballMatrix(n1:Number3D,n2:Number3D,center:Number3D=
null,oMatrix:MatrixAway3D=null):MatrixAway3D
                {

                        if(center == null) center = new Number3D;
                        var p1:Number3D =n1
                        p1.sub(p1,center);
                        p1.normalize();

                        var p2:Number3D = n2;
                        p2.sub(p2,center);
                        p2.normalize();

                        var cross:Number3D = new Number3D;
                        cross.cross(p1,p2);

                        var pos:Array = [cross.x,cross.y,cross.z]
                        var sign:Number = cross.modulo < 0 ? -1 : 1;
                        var len:Number = 
cross.modulo2//Math.sqrt(cross.x*cross.x +
cross.y*cross.y + cross.z*cross.z)
                        len*=sign;
                        var angle:Number = Math.acos(len)

                        var q:Quaternion = new Quaternion;
                        q.axis2quaternion(pos[0],pos[1],pos[2],angle);
                        q.normalize(1)
                        var mat:MatrixAway3D = new MatrixAway3D;
                        mat.quaternion2matrix(q);

                        mat.normalize(mat)

                        return mat;
                }

Reply via email to