Help with dot product

image

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

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

thank you for the pro math tip.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.