Oh good point, I mixed up some math lingo . Thanks for the feedback.pgimeno wrote: ↑Sun Feb 21, 2021 3:18 am No, the w of a quaternion is not the angle! It's the real component, which for a quaternion representing a pure rotation (i.e. normalized), equals the cosine of half the rotation angle. The name of the function suggests that it accepts a quaternion, but an axis/angle rotation is not a quaternion, even if the conversion to quaternion is fairly simple. That's why I suggest choosing a name that doesn't cause this confusion. A quaternion is what you use internally as rotation[1..4]. I'd expect a function called setQuaternionRotation to set rotation[1..4] to each input parameter. Something like:

Just pushed a commit to fix this by splitting the function into two:

Code: Select all

```
-- create a quaternion from an axis and an angle
function model:setAxisAngleRotation(x,y,z,angle)
x,y,z = vectorNormalize(x,y,z)
angle = angle / 2
self.rotation[1] = x * math.sin(angle)
self.rotation[2] = y * math.sin(angle)
self.rotation[3] = z * math.sin(angle)
self.rotation[4] = math.cos(angle)
self:updateMatrix()
end
-- rotate given one quaternion
function model:setQuaternionRotation(x,y,z,w)
self.rotation[1] = x
self.rotation[2] = y
self.rotation[3] = z
self.rotation[4] = w
self:updateMatrix()
end
```