1STRINGIFY(
2
3$genType cos($genType y);
4$genHType cos($genHType y);
5float dot($genType x, $genType y);
6float2x2 inverse(float2x2 m);
7float3x3 inverse(float3x3 m);
8float4x4 inverse(float4x4 m);
9$genType sin($genType x);
10$genHType sin($genHType x);
11$genType sqrt($genType x);
12$genHType sqrt($genHType x);
13$genType tan($genType x);
14$genHType tan($genHType x);
15
16float degrees(float rad) { return rad * 57.2957795; }
17float2 degrees(float2 rad) { return rad * 57.2957795; }
18float3 degrees(float3 rad) { return rad * 57.2957795; }
19float4 degrees(float4 rad) { return rad * 57.2957795; }
20
21float radians(float deg) { return deg * 0.0174532925; }
22float2 radians(float2 deg) { return deg * 0.0174532925; }
23float3 radians(float3 deg) { return deg * 0.0174532925; }
24float4 radians(float4 deg) { return deg * 0.0174532925; }
25
26float length(float2 v) { return sqrt(dot(v, v)); }
27float length(float3 v) { return sqrt(dot(v, v)); }
28float length(float4 v) { return sqrt(dot(v, v)); }
29
30float distance(float2 a, float2 b) { return length(a - b); }
31float distance(float3 a, float3 b) { return length(a - b); }
32float distance(float4 a, float4 b) { return length(a - b); }
33
34float2 normalize(float2 v) { return v / length(v); }
35float3 normalize(float3 v) { return v / length(v); }
36float4 normalize(float4 v) { return v / length(v); }
37
38float mix(float x, float y, float t) { return x * (1 - t) + y * t; }
39float2 mix(float2 x, float2 y, float t) { return x * (1 - t) + y * t; }
40float3 mix(float3 x, float3 y, float t) { return x * (1 - t) + y * t; }
41float4 mix(float4 x, float4 y, float t) { return x * (1 - t) + y * t; }
42
43float2 mix(float2 x, float2 y, float2 t) { return x * (1 - t) + y * t; }
44float3 mix(float3 x, float3 y, float3 t) { return x * (1 - t) + y * t; }
45float4 mix(float4 x, float4 y, float4 t) { return x * (1 - t) + y * t; }
46
47float3 cross(float3 a, float3 b) {
48 return float3(a.y * b.z - a.z * b.y,
49 a.z * b.x - a.x * b.z,
50 a.x * b.y - a.y * b.x);
51}
52
53)
54