D.J.Peters wrote:@dafhi @gothon first you think it's clever but in practice it looks different.
If you get any surface normal (it points in any direction)
1) how you would select a precalculated random vector ?
(as a minimum you have to get the right qudrant from sphere to chose one)
I suggested pre-computing a random low angle rotation matrix not a vector. A simple way to do this might be to make a small random rotation about the X, Y and Z axis, then multiplying all three rotations into one 3x3 matrix.
https://en.wikipedia.org/wiki/Rotation_ ... _rotations
Though there are probably other methods as-well since you might find a method giving you a more desirable distribution of rotations.
D.J.Peters wrote:2) more important how to rotate any new random vector does it fits the cone ?
(I think a hour about it but I don't get it)
Once you have a rotation matrix, you simply multiply it by your vector to apply the rotation.
U.X = V.X * m_00 + V.Y * m_01 + V.Z * m_02
U.Y = V.X * m_10 + V.Y * m_11 + V.Z * m_12
U.Z = V.X * m_20 + V.Y * m_21 + V.Z * m_22
(9 multiplications and 6 additions)
D.J.Peters wrote:Show me the code if you like please
Yep, real code is best, but hold on as it will take me a bit of time to write it and debug it. :)