Rotating a line to a specified angle on a monitor

Started by atheek, May 21, 2024, 12:14 PM

Previous topic - Next topic

atheek

I want to rotate a line to an angle specified I have no idea how id go about this.

QuickMuffin8782

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!
"The Blue Blur" - Working on Net Star OS, a new frontier for Red Star OS 3.0
Gitlab - Join my official discord! - SS Discord