New answers tagged

0

Ok, i didn't read carefully enough the documentations, it states that: q.x = sin(theta/2) * axis.x q.y = sin(theta/2) * axis.y q.z = sin(theta/2) * axis.z q.w = cos(theta/2) so in my case i had to write: D3DXQUATERNION tempRot1(0.0f, sin(XM_PIDIV2 / 2), 0.0f, cos(XM_PIDIV2 / 2));


0

Quaternions are different than Euler angles; Euler angles has 3 components (x, y, z) while Quaternions has 4 (x, y, z, w). If you want your result in Euler angles, use following code piece: Quaternion LeftTurnLimit = Quaternion.identity; float test = 0.1f; LeftTurnLimit = Quaternion.Euler(test, 0, 0); var LeftTurnLimitEuler = LeftTurnLimit.eulerAngles; ...


4

Rounding. If you attach the debugger and look at the values of your quaternion: You'll see that the values are just too small to be displayed with one tenth precision, as the debug value is displayed. You can confirm this by looking at: Debug.Log(LeftTurnLimit.eulerAngles); This will output the initial value you put in : 0.1, 0, 0 To address the ...


1

For posterity...it ended up being a simple handedness issue, but only around the Y (pitch) axis. I had it stuck in my head that positive pitch increases Z and negative pitch decreases Z, which isn't true in a right-hand system. Lesson learned!


2

Both XNA and Fabian Giesen’s implementation behave correctly. Transforming vector (1, 0, 0) by quaternion (w=0.6532815, x=-0.270598, y=0.270598, z=0.6532815) does resut in (0, 0.7071, -0.7071). It also does in Unreal Engine, in my own quaternion implementation, as well as in Wolfram Alpha. Wolfram Alpha also gives the 3×3 matrix equivalent of the ...


0

You are most of the way there already. The problem is, OnTriggerEnter only happens once. Quaternion.Lerp changes the value over time, at the speed specified by the timestep. Since it is only being called once, it will only move the rotation one step. In this case, .1f * Time.deltaTime is your step. This is a very small number. It needs to move that small of ...


0

Looks like you need to restrict the euler angles of the turret, after the quaternion rotation has been effected. basically you'd just do something like: transform.localEulerAngles = new Vector3(transform.localEulerAngles.x < 0 ? 0 : transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z); ...I think X is the right axis ...



Top 50 recent answers are included