C
C#17mo 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
Thinker17mo ago
I think it's atan2(y, x)...?
TheSnowOwl
TheSnowOwl17mo ago
yes vector2 ill try...
MODiX
MODiX17mo 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
MODiX17mo 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
Thinker17mo ago
yeah it's atan2 given this is in radians
TheSnowOwl
TheSnowOwl17mo ago
that'll work too i dont understand >.< i feel stupid my math ain't mathing
Thinker
Thinker17mo 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
Thinker17mo 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
Accord17mo 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
More Posts
❔ How can I better understand the concepts of unit of work and repository pattern in C# .NET 7?I am seeking assistance in understanding the unit of work and repository pattern in C#.NET7. While I❔ Help with a unity Inventoryim making an Inventory for my unity game and im getting this CS1061 error, i Know what the error is,❔ Running an awaitable async Task, but forcing it to run on a specific thread (main thread).Hi everyone, I'm doing some work in Unity and am having an issue where some of the code that I want ❔ Help connect VS-Code to Unity and Simplify running programI want to connect Unity and VS code Also ive done it before but i want to simplify how you run the ❔ Issue with unit testing and projects not startingI'm writing up tests for my controller, but I need to grab an access token for authorization to do a❔ Retrieve API data in C#What structure would you use if you want to create an API that retrieves data from another API and r❔ HttpRequestException: No Such Host is known. (url.com:443) using WorkerService issueGreetings! I'm getting this error when my Win Service attempts to connect to my endpoint. It throws ✅ api response 401hey, I'm trying to use nlpcloud to translate text there is curl example: ```cpp curl "https://api.nl✅ warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible.I'm doing some codes in visual code and I don't what's wrong exactly. So the thing is I did a localh❔ Is there any way to create a pointer to a C# generic classI have a script that uses a class "fogGrid<bool>". At the start of the script I want it to be able t