Community
Navisworks Forum
Welcome to Autodesk’s Navisworks Forums. Share your knowledge, ask questions, and explore popular Navisworks topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Quaternion function - for viewpoint export/import

2 REPLIES 2
Reply
Message 1 of 3
TonyDDao
1249 Views, 2 Replies

Quaternion function - for viewpoint export/import

Does anyone know the formula used to calculate "quaternion" used by Naviswork?
Even better if AutoDesk insider or formal Naviswork developer team post the software code that does this.

What for and who would be interested?
To convert saved "viewpoints" in Naviswork to/from Aveva Design Review or Intergraph Design Review.

The position of the viewpoint is common stored and export as 3D XYZ co ordinates:

Naviswork XML View point:
Aveva Design Review : 4526.105 6746.866 326.793

However the view direction is slightly different.

In Naviswork, during editing "Viewpoint" GUI, the view direction is also a 3D XYZ co ordinates, also matching Avea Design Review viewpoint view direction as 3D XYZ co-ordinates.

The issue is with Naviswork Viewpoint XML export do not use a 3D XYZ co-ordinate for the direction of the view point.
It uses. "Quaternion"


Some where in between the Naviswork GUI where the user enter
- View Position XYZ
- View Direction XYZ
Naviswork calculate the "quaternion" for the Viewpoint XML export.

What the formula to calculate a,b,x,d ? Edited by: TonyDao8236 on May 24, 2010 11:56 PM
2 REPLIES 2
Message 2 of 3

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?

Message 3 of 3
thu-cp
in reply to: TonyDDao

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report