Recently when I made the CSS3 box-shadow generator I tried to make something new and make it possible for user to select angle and it will generate horizontal and vertical distance from it. From my Physics classes I get to know some basics formula to generate components from a vector.
Check out the image below:
According to formula,
Vx=(V)(Cosθ)Lets calculate them simultaneously, Vx need distance and θ value to return value. So taking distance as 100 (pixels) and θ as 45 degrees.
Conversion of radians into degrees
Math.PI * (theta / 180);
var distance = 100,
theta = 45,
sinfun = Math.sin(Math.PI * (theta / 180))*distance,
cosfun = Math.cos(Math.PI * (theta / 180))*distance;