random points around an axis

Started by
2 comments, last by guptan 12 years, 1 month ago
I want to get a set of random vectors from a hit point when I cast a ray.
The random vectors should be inside a cone.
Please help.
Advertisement
I will give you more details to my question. This is originally for spewing a set of billboards.

When the player shoots a target, a ray is casted towards the target to find the hit point. now hit point - rayDir * randomDistance will give me a point along the ray. Now I want this point to be rotated around the negated rayDir at an angle.

How do I do that?
I can divide the problem into two simpler problems for you. First, generate the distribution you want around a reference vector, say (1,0,0). When you are happy with the distribution, you need to rotate the results using a rotation that would map (1,0,0) to line up with -rayDir. Give it a try, and post back if you have trouble with either of the two steps.
Thank you. I did it with your help.

This topic is closed to new replies.

Advertisement