lygia
/v1.1.6
/math
/rotate4d
)returns a 4x4 rotation matrix
Use:
rotate4d(<vec3> axis, <float> radians)
#ifndef FNC_ROTATE4D
#define FNC_ROTATE4D
mat4 rotate4d(in vec3 a, in float r) {
a = normalize(a);
float s = sin(r);
float c = cos(r);
float oc = 1.0 - c;
return mat4(oc * a.x * a.x + c, oc * a.x * a.y - a.z * s, oc * a.z * a.x + a.y * s, 0.0,
oc * a.x * a.y + a.z * s, oc * a.y * a.y + c, oc * a.y * a.z - a.x * s, 0.0,
oc * a.z * a.x - a.y * s, oc * a.y * a.z + a.x * s, oc * a.z * a.z + c, 0.0,
0.0, 0.0, 0.0, 1.0);
}
#endif
Use:
rotate4d(<float3> axis, <float> radians)
#ifndef FNC_ROTATE4D
#define FNC_ROTATE4D
float4x4 rotate4d(in float3 axis, in float radians) {
axis = normalize(axis);
float s = sin(radians);
float c = cos(radians);
float oc = 1.0 - c;
return float4x4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0);
}
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository