public bool RotateScene(warp_Quaternion quat) { if (_scene == null) { return(false); } _scene.rotate(quat); return(true); }
static public warp_Quaternion matrix(warp_Matrix xfrm) { warp_Quaternion quat = new warp_Quaternion(); // Check the sum of the diagonal float tr = xfrm [0, 0] + xfrm [1, 1] + xfrm [2, 2]; if (tr > 0.0f) { // The sum is positive // 4 muls, 1 div, 6 adds, 1 trig function call float s = (float)Math.Sqrt(tr + 1.0f); quat.W = s * 0.5f; s = 0.5f / s; quat.X = (xfrm [1, 2] - xfrm [2, 1]) * s; quat.Y = (xfrm [2, 0] - xfrm [0, 2]) * s; quat.Z = (xfrm [0, 1] - xfrm [1, 0]) * s; } else { // The sum is negative // 4 muls, 1 div, 8 adds, 1 trig function call int[] nIndex = { 1, 2, 0 }; int i, j, k; i = 0; if (xfrm [1, 1] > xfrm [i, i]) { i = 1; } if (xfrm [2, 2] > xfrm [i, i]) { i = 2; } j = nIndex [i]; k = nIndex [j]; float s = (float)Math.Sqrt((xfrm [i, i] - (xfrm [j, j] + xfrm [k, k])) + 1.0f); quat [i] = s * 0.5f; if (!warp_Math.FloatApproxEqual(s, 0.0f)) { s = 0.5f / s; } quat [j] = (xfrm [i, j] + xfrm [j, i]) * s; quat [k] = (xfrm [i, k] + xfrm [k, i]) * s; quat [3] = (xfrm [j, k] - xfrm [k, j]) * s; } return(quat); }
public bool RotateSelf(string name, warp_Quaternion quat) { if (_scene == null) { return(false); } warp_Object o = _scene.sceneobject(name); if (o == null) { return(false); } o.rotateSelf(quat); return(true); }
static public warp_Quaternion matrix (warp_Matrix xfrm) { warp_Quaternion quat = new warp_Quaternion (); // Check the sum of the diagonal float tr = xfrm [0, 0] + xfrm [1, 1] + xfrm [2, 2]; if (tr > 0.0f) { // The sum is positive // 4 muls, 1 div, 6 adds, 1 trig function call float s = (float)Math.Sqrt (tr + 1.0f); quat.W = s * 0.5f; s = 0.5f / s; quat.X = (xfrm [1, 2] - xfrm [2, 1]) * s; quat.Y = (xfrm [2, 0] - xfrm [0, 2]) * s; quat.Z = (xfrm [0, 1] - xfrm [1, 0]) * s; } else { // The sum is negative // 4 muls, 1 div, 8 adds, 1 trig function call int[] nIndex = { 1, 2, 0 }; int i, j, k; i = 0; if (xfrm [1, 1] > xfrm [i, i]) i = 1; if (xfrm [2, 2] > xfrm [i, i]) i = 2; j = nIndex [i]; k = nIndex [j]; float s = (float)Math.Sqrt ((xfrm [i, i] - (xfrm [j, j] + xfrm [k, k])) + 1.0f); quat [i] = s * 0.5f; if (s != 0.0) { s = 0.5f / s; } quat [j] = (xfrm [i, j] + xfrm [j, i]) * s; quat [k] = (xfrm [i, k] + xfrm [k, i]) * s; quat [3] = (xfrm [j, k] - xfrm [k, j]) * s; } return quat; }
public bool RotateSelf (string name, warp_Quaternion quat) { if (_scene == null) { return false; } warp_Object o = _scene.sceneobject (name); if (o == null) { return false; } o.rotateSelf (quat); return true; }
public bool RotateScene (warp_Quaternion quat) { if (_scene == null) { return false; } _scene.rotate (quat); return true; }