Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float cone_angle = (float)(R.NextDouble() * angleDiff);
- float roll = (float)(R.NextDouble() * 360.0);
- Vector3 ray = reflectedRay.Direction;
- Vector3 normal =
- ray.X == 0 ? new Vector3(1, 0, 0) :
- ray.Y == 0 ? new Vector3(0, 1, 0) :
- ray.Z == 0 ? new Vector3(0, 0, 1) : new Vector3(-ray.Y, ray.X, 0);
- Matrix rot_cone = Matrix.CreateFromAxisAngle(normal, MathHelper.ToRadians(cone_angle));
- Matrix rot360 = Matrix.CreateFromAxisAngle(ray, MathHelper.ToRadians(roll));
- Matrix trans = Matrix.CreateTranslation(ray);
- Matrix itrans = Matrix.CreateTranslation(-ray);
- Vector3 result = Vector3.Transform(ray, (rot360 * rot_cone));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement