///////////////////////////////////////////////////// // VectorTransform : // these algorithms are from // http://www.erols.com/vansickl/matrix.htm // by John VanSickl. It was converted into macro // form by Dan Connelly ( djconnel@flash.net ) on // 26Sept1998. #ifdef ( VectorTranform_Inc ) #else #declare VectorTranform_Inc = version; #version 3.1; ///////////////////////////////////////////////////// // VectorAlign : // This returns a tranformation which takes something // pointing in the direction of V1 and makes it point // in the direction of V2. Note this transformation // is not unique (an additional degree of freedom // is provided by an initial rotation about V1). #macro VectorAlign(V1, V2) #local VX1=vnormalize(V1); #local VX2=vnormalize(V2); #local VY=vnormalize(vcross(VX2,VX1)); #local VZ1=vcross(VY,VX1); #local VZ2=vcross(VY,VX2); matrix < VX1.x, VY.x, VZ1.x, VX1.y, VY.y, VZ1.y, VX1.z, VY.z, VZ1.z, 0 0 0 > matrix < VX2.x, VX2.y, VX2.z, VY.x, VY.y, VY.z, VZ2.x, VZ2.y, VZ2.z, 0, 0, 0 > #end ///////////////////////////////////////////////////// // VectorRotate : // This returns a tranformation which rotates // about the axis V an angle T in degrees #macro VectorRotate(V, T) #local VX = vnormalize(V); #local VY = vnormalize(vcross(VX,)); #local VZ = vnormalize(vcross(VX,VY)); matrix < VX.x,VY.x,VZ.x, VX.y,VY.y,VZ.y, VX.z,VY.z,VZ.z, 0, 0, 0 > rotate x*T matrix < VX.x,VX.y,VX.z, VY.x,VY.y,VY.z, VZ.x,VZ.y,VZ.z, 0, 0, 0 > #end #version VectorTranform_Inc; #end