Hi,
I’m using this code to get rotation from current position to another position:
local angle = math.atan2(self.target.y - go.get_position().y, self.target.x - go.get_position().x)
Then the code will set rotation of another object to get his rotation in degrees by euler.z.
go.set_rotation(vmath.quat_rotation_z(angle), "rotor")
rot = math.floor(go.get(".", "euler.z"))
But the information obtained by euler.z is not in the 360 degree spectrum, but in numbers from -180 to 180, so I’m still converting the number to the 360 degree spectrum using this code:
rot = rot + 360
if rot > 360 then
rot = rot - 360
end
It’s quite complicated and I also need a second object, which only serves to set the rotation to a certain point, so that it can then provide the information in euler.z, which is then converted.
local angle = math.atan2(self.target.y - go.get_position().y, self.target.x -
go.get_position().x)
Could I somehow avoid this and get the information straight by converting the vmath.vector4 rotation obtained from this line of code to a degree? And why is euler.z not in the 360 degree spectrum at all?
Thank you in advance for your answers.