Hello everyone!
I need some help with figuring out how I can convert a point on a circle to a point on a square.
This is what I have right now:
local function convCircSquare(beginning, radius, theta)
local u = (radius * cos(theta))
local v = (radius * sin(theta))
local usq = u * u;
local vsq = v * v;
local fu = twoSqrt2 * u;
local fv = twoSqrt2 * v;
local x =
0.5 * sqrt(2 + fu + usq - vsq) - 0.5 * sqrt(2 - fu + usq - vsq);
local z =
0.5 * sqrt(2 + fv - usq + vsq) - 0.5 * sqrt(2 - fv - usq + vsq);
x = tostring(x) == "-nan(ind)" and 0 or x
z = tostring(z) == "-nan(ind)" and 0 or z
x = beginning.X + x
z = beginning.Z + z
return Vector3.new(x,beginning.Y,z)
end
But it doesn’t work correctly.
If anyone has any ideas on how this could be done it would be highly appreciated