# Angle to Vector3?

I am working on getting my directional lights to match the sun in my atmospheric scattering shader.

I have a float that ranges from 0 to 6.28 (TwoPi). How would I calculate a vector3 from this angle?

The reason I need an angle is because my light angle is created like this:

LookAt(new Vector3(100, 100, 100), Vector3.Zero, Vector3.Forward);


Thanks.

The angle is an angle in 2D plane, correct? Then you need simple trigonometry:

Vector3 myVector = new Vector3(Math.cos(angleFloat), Math.sin(angleFloat), 0);


Look at this image. In your case, V = 1. If you need vector in different plane, just switch the axes. Note: The code is in Java, but whatever language you use, it should be very similar.

• If I needed to calculate the third element, it would be using Cos, right? Jul 8, 2013 at 7:39
• To non-ambiguously define a vector in 3D space you need 2 variables (like latitude, longitude). So unless you know around which axis this angle is you need more information to define the vector. Jul 8, 2013 at 11:28