I'm curious too. The a/b/c/d of navisworks quaternion stored in the xml doesn't seem to correlate with other quaternion formulas I've found. Can someone explain what formula is being used or how this relates to other quaternions?
I've found out that the a,b,d,c of navisworks quaternion can be calculated by coversing Rotation matrix to Quaternion. The theory behind this calculation is in the link below:
https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
First you need the Direction and the Up vector, then define the new x,y axises by finding their cross product. Next is to create a rotation matrix from them and converse it to quaternion.
Here are the python codes that I used:
***qw, qx, qy, qz are a, b, c, d alternatively
#-------------------------------------------
up = Vector.ByCoordinates(0,0,-1)
xaxis = Vector.Normalized(Vector.Cross(up, direction))
yaxis = Vector.Normalized(Vector.Cross(direction,xaxis))
m = [[] for j in range(3)]
#row1
m[0].append(xaxis.X)
m[0].append(yaxis.X)
m[0].append(direction.X)
#row2
m[1].append(xaxis.Y)
m[1].append(yaxis.Y)
m[1].append(direction.Y)
#row3
m[2].append(xaxis.Z)
m[2].append(yaxis.Z)
m[2].append(direction.Z)
qw = math.sqrt(1 + m[0][0] + m[1][1] + m[2][2])/2
qz = -(m[2][1] - m[1][2]) / (4*qw)
qy = -(m[0][2] - m[2][0])/( 4 *qw)
qx = (m[1][0] - m[0][1])/( 4 *qw)
return qw, qx, qy, qz