Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

SharpDX.Quaternion Axis property #328

Closed
ngocnl opened this issue Apr 1, 2014 · 3 comments
Closed

SharpDX.Quaternion Axis property #328

ngocnl opened this issue Apr 1, 2014 · 3 comments
Labels

Comments

@ngocnl
Copy link

ngocnl commented Apr 1, 2014

SharpDX.Quaternion Axis property returns incorrect result.

length calculation should be revised as: float length = (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z)); (see code)

@ArtiomCiumac
Copy link
Contributor

Do you have any links that describe the correct implementation? We may need to add a call to Math.Sqrt in the line 230, but definitely not in the place you pointed - as the call to Sqrt may not be necessary in the case when the length is zero.

@ngocnl
Copy link
Author

ngocnl commented Apr 1, 2014

I use the formula at below link and I think it is correct. I can re-build a same quaternion from axis & angle from original quaternion.

http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/

In that, they use sqrt(1- w_w), and it is same as sqrt(x_x + y_y + z_z) when the quaternion is normalized. Calling Math.Sqrt at line 230 is ok also.

@ArtiomCiumac
Copy link
Contributor

Thank you for information. This should be fixed now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants