domi_AU
(domi)
October 14, 2023, 11:54am
#1
I’ve found out printing
math.deg(math.acos(.5)) results in 60
math.deg(math.acos(0)) results in 90
So how could i use math functions in a way that can turn 60 into 0.5 and 90 into 0?
Im trying to calculate a NPC’s point of view by the way,
I want them to have easily changable detection angles.
Sorry if I explained this poorly im not very good at math.
3 Likes
math.cos(math.rad(60)) → 0.5
math.cos(math.rad(90)) → 0
Since cos and acos are each others’ inverse functions, and same with rad and deg. E.g.
math.acos(math.cos(x)) → x
math.cos(math.acos(x)) → x
math.deg(math.rad(a)) → a
math.rad(math.deg(a)) → a
1 Like
NGC4637
(NoMore_Sugarcoating)
October 14, 2023, 1:17pm
#3
pro tip: math.cos
is the exact opposite of math.acos
, math.rad
is the exact opposite of math.deg
so what we can do is this:
print(math.cos(math.rad(60))) -- 60 into 0.5. (when i tested it, it gave me 0.5000000001, but it should be close enough lol
print(math.cos(math.rad(90))) -- 90 into 0.
2 Likes
domi_AU
(domi)
October 14, 2023, 1:52pm
#4
thank you for the pro math tip.
system
(system)
Closed
October 28, 2023, 1:52pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.