Advertisement
timeshifter

Untitled

Jan 22nd, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. float cone_angle = (float)(R.NextDouble() * angleDiff);
  2. float roll = (float)(R.NextDouble() * 360.0);
  3.  
  4. Vector3 ray = reflectedRay.Direction;
  5.  
  6. Vector3 normal =
  7.     ray.X == 0 ? new Vector3(1, 0, 0) :
  8.     ray.Y == 0 ? new Vector3(0, 1, 0) :
  9.     ray.Z == 0 ? new Vector3(0, 0, 1) : new Vector3(-ray.Y, ray.X, 0);
  10.  
  11. Matrix rot_cone = Matrix.CreateFromAxisAngle(normal, MathHelper.ToRadians(cone_angle));
  12. Matrix rot360 = Matrix.CreateFromAxisAngle(ray, MathHelper.ToRadians(roll));
  13. Matrix trans = Matrix.CreateTranslation(ray);
  14. Matrix itrans = Matrix.CreateTranslation(-ray);
  15.  
  16. Vector3 result = Vector3.Transform(ray, (rot360  * rot_cone));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement