random points around an axis

This topic is 2467 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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.

Share on other sites
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?

Share on other sites
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.

Share on other sites
Thank you. I did it with your help.

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633744
• Total Posts
3013654
×

Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!