Signature
stock xs_vec_reflect(const Float:vec[], const Float:normal[], Float:out[]){ // normalize(vec) - (normal * 2.0 * (tmp . normal)) * length(vec) new Float:tmp1[3]; xs_vec_normalize(vec, tmp1); // tmp1 - (normal * 2.0 * (tmp . normal)) * length(vec) new Float:tmp2[3]; xs_vec_mul_scalar(normal, 2.0, tmp2); xs_vec_mul_scalar(tmp2, xs_vec_dot(tmp1, normal), tmp2); // tmp1 - tmp2 * length(vec) xs_vec_mul_scalar(tmp2, xs_vec_len(vec), tmp2); // tmp1 - tmp2 xs_vec_sub(tmp1, tmp2, out);}
Description
Reflects a vector about a normal.
Parameters
- vec — The vector to be reflected.
- normal — The normal vector about which to reflect.
- out — The output reflected vector.
No return value