ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: atheek on May 21, 2024, 12:14 PM

Title: Rotating a line to a specified angle on a monitor
Post by: atheek on May 21, 2024, 12:14 PM
I want to rotate a line to an angle specified I have no idea how id go about this.
Title: Rotating a line to a specified angle on a monitor
Post by: Purrcival on Jun 20, 2024, 04:43 AM
Quote from: atheek on May 21, 2024, 12:14 PMI want to rotate a line to an angle specified I have no idea how id go about this.

There is a way to do so using Degrees via the Sine and Cosine functions.
local degree = 180 --the degree you want
local magnitude = 5 --how big it is (also goes negative)

local calcx, calcy = math.sin(degree) * magnitude, math.cos(degree) * magnitude

Same but with a function:
function getrotationvalue(deg, mag)
    local degree = deg
    local magnitude = mag

    local calcx, calcy = math.sin(degree) * magnitude, math.cos(degree) * magnitude
    return calcx, calcy
end

Hope this helps understading this issue you're having!