Archive for the ‘math’ Category

October 23, 2012 0

Calculating the gravity of the gravitational force or 0.00000000000667

By in math, snippet, sourcecode

Gravity is by far the best force in the universe. Despite being the weakest of the “main” four (strong nuclear force, weak nuclear force, electromagnetism, gravity). It is the one that dominates given enough time and distances. All this even though it falls of inversely to the square of the distance, meaning, if you double […]

September 10, 2011 0

Getting the angle between two 3D vectors

By in math, snippet

Another short post related to a question I was asked, that I figure might be helpful to others. Getting the angle between two vectors in 2D is as simple as: var angle = Math.atan2(vectorA.y – vectorB.y, vectorA.x – vectorB.x) However that does not work in 3D space, however the angle between any two vectors (2D […]

September 10, 2011 1

Rotate vector / line-segment / polygon around arbitrary point

By in math, snippet

Someone asked me this earlier today, and i made this code snippet and I figured i might as well share it and save it for myself. To rotate a vector, or for that matter a linesegment (which is just two vectors), and again a polygon (which is just n linesegments). All you have to do […]