So, my issue concerns vectors, I don’t know where I’m going with that case. I’m building a pandemic simulation (using Javascript and the library p5.js), and I’m trying to add a lockdown feature. Here is an image to make everything clearer: Essentially, at the moment, when two molecules collide, their velocity vector change appropriately by switching their former velocity. My
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 unsure how to obtain (get) an angle from a
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 should note also that you may want
Three.js – Rotating a sphere around a certain axis
I have a problem. In Three.js, I want to rotate a sphere (Earth) around axis tilted by 23.5 degs. I found sphere.rotation.x, sphere.rotation.y and sphere.rotation.z, but when I combine them in the correct ratio, the sphere’s rotation is quite weird – it has no permanent rotation axis. I think I need a function like sphere.rotation.vector(1,0,-1). Does anyone know how this