diff options
| author | yum <yum.food.vr@gmail.com> | 2025-10-10 22:53:26 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-10-10 22:54:28 -0700 |
| commit | 4cbf98dd43ebb4795fe36faa68b858602a4044f3 (patch) | |
| tree | 006f9f024eae1dcdb8932038865933bb944abb53 /test.slang | |
initial commit
Diffstat (limited to 'test.slang')
| -rw-r--r-- | test.slang | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test.slang b/test.slang new file mode 100644 index 0000000..324e53f --- /dev/null +++ b/test.slang @@ -0,0 +1,24 @@ +#ifndef __CUSTOM31_INC +#define __CUSTOM31_INC + +[Differentiable] +public float3 cart_to_cyl(uniform float3 xyz) { + float radius = length(xyz.xy); + float theta = atan2(xyz.y, xyz.x); + return float3(radius, theta, xyz.z); +} + +public float3x3 cart_to_cyl_jacobian(uniform float3 xyz, uniform float3 n) { + DifferentialPair<float3> dp_x = diffPair(xyz, float3(1, 0, 0)); + DifferentialPair<float3> dp_y = diffPair(xyz, float3(0, 1, 0)); + DifferentialPair<float3> dp_z = diffPair(xyz, float3(0, 0, 1)); + + DifferentialPair<float3> dp_x_out = fwd_diff(cart_to_cyl)(dp_x); + DifferentialPair<float3> dp_y_out = fwd_diff(cart_to_cyl)(dp_y); + DifferentialPair<float3> dp_z_out = fwd_diff(cart_to_cyl)(dp_z); + + return float3x3(dp_x_out.d, dp_y_out.d, dp_z_out.d); +} + +#endif // __CUSTOM31_INC + |
