Skip to content
Discussion options

You must be logged in to vote
import drjit as dr
import mitsuba as mi

mi.set_variant('cuda_ad_rgb')

p = mi.Float(0)
dr.enable_grad(p)

transform = mi.Transform4f.translate(mi.Vector3f(0, p, 0))

dr.forward(p, dr.ADFlag.ClearEdges)

print(dr.grad(transform.matrix))
print(dr.grad(transform.inverse_transpose))

This returns

[[[0.0, 0.0, 0.0, 0.0],
  [0.0, 0.0, 0.0, 1.0],
  [0.0, 0.0, 0.0, 0.0],
  [0.0, 0.0, 0.0, 0.0]]]
[[[0.0, 0.0, 0.0, 0.0],
  [0.0, 0.0, 0.0, 0.0],
  [0.0, 0.0, 0.0, 0.0],
  [0.0, -1.0, 0.0, 0.0]]]

mi.transform is a struct that store both the matrix and the inverse transpose. In the computational graph, the inverse transpose is computed from the matrix itself.
dr.forward with the default flag cleans e…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@zichenwang01
Comment options

@ziyi-zhang
Comment options

Answer selected by zichenwang01
@zichenwang01
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants