I have two questions. Code below is reconstructed from memory, i don’t have my ipad with me, so it might be wrongly coded… oh well.
the first example is supposed to be a sine calculator (basically math.sin). I can’t get it to increase accuracy beyond a certain number of digits. I don’t need that accuracy now (and probably never), but I wanted to be able to do it
local function factorial(n)
assert( n > 1 )
local v = 1
for x= 2, n do
v = v * x
end
return v
end
function mySine(number)
local power = 3 -- n^3/3!, n^5/5!, ...
local result = number
for x = 1, 10 do
if x % 2 == 1 then -- subtract
result = result - number ^ power/factorial(power)
else
result = result + number ^ power/factorial(power)
end
power = power + 2
end
return result
end
Second question
I have a ship class. So it’s a really simple Asteroids style ship. I tried using the Law of Sines to calculate the sides, but it didn’t work right (so Law of sines is side a/sine(A) = side b/sine(B) = side c/sine(C) ) (i got what I felt was the wrong values when I inputted a known angle to a known side)
Umm, that wasn’t the question. The question is:
Where is the y position on this triangle of point c
point a is at 0,0
point b is at 24,0
point c is at 12, ?
angle a is 70*
angle b is 70*
angle c is 40*
local y
-- y should be calculated from the angles of the triangle.
--
mesh = mesh()
mesh.vertices = {vec2(0,0), vec2(24,0), vec2(12, y)}
-- angle at 0,0 is 70*
-- angle at 24,0 is also 70*
-- angle at the third point should be 40*