This question is mostly math related…
How do I create this function WITHOUT using Instance.new()
or anything outside of a script.
Here the red line is glitched into the green one, its the diameter of the circle.
As you can see it returns the length of the red line
with the use of θ
where the circle’s radius is 1
if anyone knows whats the formula to the function please lmk :)))
2 Likes
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:46am
#2
you probably cant if it not parts or whatever is this
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:48am
#3
if its parts or Ui element then you can use position and size to determen the position and then CFrame (if parts) to look at eachother and then apply size
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:50am
#4
and thats just for only red line.
for green and blue. u set blue as it stays for center aka 0
and rotate green at the center first and then adding position that will make green line not in center but at its position like the example
I mean i want to create a function just inside a script to achieve it.
like
function f(x)
🤔
end
print(f(90)) --> sqrt(2) (lazy to write it out)
print(f(180)) --> 2
print(f(45)) --> sqrt(1/2) (lazyyyy)
Boustifail
(Boustifail)
September 14, 2023, 11:51am
#6
Maybe you can take a look at this post:
The Maths
The math needed for this is basic knowledge of trigonometric functions and of dot products, which you can find here and here respectively.
with that said, lets dive in!
The circle
[image]
above image represents the unit circle
the text indicates the rotation in radians at each point, for those of you unfamiliar with radians, pi radians is 180 degrees.
This shows the rotations counterclockwise, you should also know that rotations that are clockwise are considered negative and ca…
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:51am
#7
i told you how but we cant write code for people thats againts the rules…
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:52am
#8
but for the rotation use math.rad
Ik but i need it to not use instances
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:53am
#10
im not sure if you can even make something without instances because its like everywhere
FoxTermBit
(FoxTermBit)
September 14, 2023, 11:53am
#11
even the script is an instance :T
i meant the script shouldnt use instances.
like sin, cos, tan, cot, sec, csc is possible, why isnt this?
Boustifail
(Boustifail)
September 14, 2023, 11:55am
#13
If you don’t want to use Instance.new() you have 2 choices:
take an existing instance and base your calculs over it
take defined numbers and base your calcul over it
1 Like
But like… what numbers do i use…?
What numbers should be used for this function?
like to get a circumference u do f(x)=x*π
so u use pi there
what do i use here…
Boustifail
(Boustifail)
September 14, 2023, 12:02pm
#15
You can do something like:
local function Calculation(x)
f(x)=x*π
end
print(Calculation(15))
that doesnt make any sense…
f(x)=x*π ← that is a mathematical function, not a lua function
Boustifail
(Boustifail)
September 14, 2023, 12:05pm
#17
It was just an example to see how to do a function without using any instance. After that, you will have to create yourself the calcul inside
Boustifail
(Boustifail)
September 14, 2023, 12:05pm
#18
local function Calculation(x)
local pi = 3.14
x = x ^ 2
x = x * pi
return x
end
print(Calculation(15))
first, this code is straight up bull___t.
...
Boustifail:
local pi = 3.14
pi already has a built in version, math.pi
Boustifail:
x ^ 2 = x * pi
x^2 is an existing function and you cant set what it results as.
Boustifail:
print(Calculation(15))
this would print
everytime because you didnt return anything.
I dont really think you understood my question…
Boustifail
(Boustifail)
September 14, 2023, 12:11pm
#20
I gave an example and yeah, i added a return now (just forgot it). have a good day