C
C#2y ago
TheSnowOwl

❔ How can i calculate a rotation float from a direction vector?

i know this might not be the correct place to ask such a question, but i figured such a large number of capable minds, surely there is someone who can explain it to me :> anyway, as i said in the title, i want to calculate a rotation based on a directional vector. i suck at math, and i cant find my answer on google, so im trying this place >.< thanks in advance <3
10 Replies
Thinker
Thinker2y ago
I think it's atan2(y, x)...?
TheSnowOwl
TheSnowOwlOP2y ago
yes vector2 ill try...
MODiX
MODiX2y ago
thinker227#5176
REPL Result: Success
MathF.Atan2(1, 1)
MathF.Atan2(1, 1)
Result: float
0.7853982
0.7853982
Compile: 470.228ms | Execution: 24.693ms | React with ❌ to remove this embed.
MODiX
MODiX2y ago
thinker227#5176
REPL Result: Success
double.Pi / 4
double.Pi / 4
Result: double
0.7853981633974483
0.7853981633974483
Compile: 409.332ms | Execution: 23.956ms | React with ❌ to remove this embed.
Thinker
Thinker2y ago
yeah it's atan2 given this is in radians
TheSnowOwl
TheSnowOwlOP2y ago
that'll work too i dont understand >.< i feel stupid my math ain't mathing
Thinker
Thinker2y ago
Trigonometric functions
In mathematics, the trigonometric functions (also called circular functions, angle functions or goniometric functions) are real functions which relate an angle of a right-angled triangle to ratios of two side lengths. They are widely used in all sciences that are related to geometry, such as navigation, solid mechanics, celestial mechanics, geod...
Thinker
Thinker2y ago
For a triangle with sides a b c where c is the hypotenuse and an angle o between a and c, tan(o) = a / b, and arctan or the inverse of tan takes the ratio a / b and returns the angle o: arctan(a / b) = o So for a 2D vector, the angle of the vector is atan(vec.y / vec.x)
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server