Skip to content

Tag: vector

Getting the angle from a direction vector?

I have this simple function to set an angle for a vector. It effectively gets the vector’s current magnitude (length), calulates the angle and converts the angle from radians to degrees. Then I apply the angle to X and Y, lastly multiplying the vector by it’s original magnitude. However I am unsur…

A Vector Class in Javascript

I’m trying to implement a vector object instantiated like below… …and when I do a math operation I need something like this… …but my code below returns me just an array Please help me out here. Thank you! Answer You need to wrap up your resulting array in a new Vector object: I s…