-- https://www.youtube.com/watch?v=7hpFYz45Odg pi = math.pi pi2 = pi*2 O=output function onTick() Distance = input.getNumber(1) if Distance < 10 then Distance = 4000 end Tilt = input.getNumber(2) if input.getBool(1) then Pitch = clamp(input.getNumber(3)-0.0625, -0.25, 0.25) else Pitch = 0 end Zoom = input.getNumber(4) xRotation = input.getNumber(5)*pi2 yRotation = Pitch*pi2 targetvZ = math.cos(yRotation) * Distance targetvY = math.sin(yRotation) * Distance targethX = math.sin(xRotation) * targetvZ targethY = math.cos(xRotation) * targetvZ p1,y1 = getPitchYaw({-3.75, 0, 0}, {targethX,targethY,targetvY}) p2,y2 = getPitchYaw({0, -6.5, 0}, {targethX,targethY,targetvY}) p3,y3 = getPitchYaw({3.75, 0, 0}, {targethX,targethY,targetvY}) p4,y4 = getPitchYaw({0, 6.5, 0}, {targethX,targethY,targetvY}) p5,y5 = getPitchYaw({0, 0, 0}, {targethX,targethY,targetvY}) outN( 1, 4*Pitch, Tilt, 4*p1,y1, 4*p2,y2, 4*p3,y3, 4*p4,y4, Zoom, targethX, targethY, targetvY, 4*p5,y5, Distance ) end function outN(o, ...) for i,v in ipairs({...}) do O.setNumber(o+i-1,v) end end --function calculatexOffset(xOffset, yOffset) -- return math.atan(targethX - (xOffset - (math.sin(xRotation)*0.375)), targethY - (yOffset - (math.cos(xRotation)*0.375))) / pi2 -- end function getPitchYaw(point1, point2)local x1, y1, z1 = point1[1], point1[2], point1[3]local x2, y2, z2 = point2[1], point2[2], point2[3]local dx = x2 - x1 local dy = y2 - y1 local dz = z2 - z1 local dxy = math.sqrt(dx * dx + dy * dy)local pitchRadians = math.atan(dz, dxy)local pitchTurns = pitchRadians / pi2 local yawRadians = math.atan(dx, dy)local yawTurns = yawRadians / pi2 if yawTurns > 0.5 then yawTurns = yawTurns - 1 elseif yawTurns < -0.5 then yawTurns = yawTurns + 1 end return pitchTurns, yawTurns end function clamp(a, b, c)return math.min(c, math.max(b, a)) end --function calculateyOffset(xOffset, yOffset) -- return math.atan(targetvZ - (xOffset - (math.sin(yRotation)*0)), targetvY - (yOffset - (math.cos(yRotation)*0))) / pi2 -- end