Hi guys
I am learning defold engine serval days ago, and today i met a problem that
the math.sin() function output a wrong result.
the code is
function update(self, dt)
-- Add update code here
-- Remove this function if not needed
self.position = go.get_position()
self.x= self.position.x
self.y= self.position.y
self.t = self.t + dt
--self.dx = math.cos(self.t * self.speed) * self.radius
--self.dy = math.sin(self.t * self.speed) * self.radius
self.dx = math.cos(self.radius) *self.t *self.speed
self.dy = math.sin(self.radius) *self.t *self.speed
self.pos = vmath.vector3()
print(dt)
print(math.cos(self.radius))
print(math.sin(self.radius))
print(self.dx)
print(self.dy)
self.pos.x = self.x + self.dx
self.pos.y = self.y + self.dy
go.set_position(self.pos)
end
but the result was a different at the angle 30.86Ā°
sin(30.86 Ā°) should be ā 0.5129 but the output was a negative value
DEBUG:SCRIPT: vmath.quat(0, 0, 0, 1)
INFO:DLIB: SSDP: Started on address 192.168.31.161
DEBUG:SCRIPT: 30.867730175872
DEBUG:SCRIPT: 0.016666667535901
DEBUG:SCRIPT: 0.85346587444752
DEBUG:SCRIPT: -0.52114873227662
so i came here to look for help, is it any wrong with my code? thanks!