If by "3d ricocheting" you mean:"Given the direction vector D of some object (a bullet) and a plane (a wall with normal vector N) which is hit by the bullet, then compute the reflection direction vector R as a reflection of D around N"then the linear algebra for this is: https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector#answer-13266