Nodes/camera-comfyUI/TrajectoryInvert
ComfyUI Node

TrajectoryInvert

Flip a trajectory between world-to-camera and camera-to-world

By Alexankharin·Created about a year ago·Updated about a month ago· 36
TrajectoryInvert
  • trajectory
  • trajectory

Every camera pose in this pack is a 4x4 matrix, and every one of them has an orientation: world-to-camera or camera-to-world. Get it backwards and your scene renders from the wrong side of the world, your splats fly off into the void, or your "forward dolly" becomes a backward panic. TrajectoryInvert is the one-node fix - it inverts each 4x4 pose in a trajectory, converting between the two conventions.

The clever bit is how it inverts. Instead of calling a generic matrix inverse, it uses the rigid-body shortcut: the rotation part transposes (R → Rᵀ) and the translation becomes −Rᵀ · t. For a proper SE(3) camera pose that's numerically stabler and exact. It handles a full [K,4,4] trajectory or a single [4,4] matrix - the single-matrix case is handy when you just need one pose flipped.

One input (trajectory), one output (trajectory). That's the whole node, and it's genuinely all it needs to be.

Where it fits in practice:

  • Before VideoToFusedSplats or SplitSplatsByMask, which expect world-to-camera poses. If your poses came out of something that hands you camera-to-world, invert the trajectory once and feed the result.
  • The retargeting recipe in this pack's docs: TrajectoryCompose(relative_path, TrajectoryInvert(source_pose0)) - invert a source pose to use it as the anchor for a composed path.
  • Sanity-checking convention drift. When a render comes out mirrored or in the wrong spot, flipping the trajectory is the cheapest hypothesis to test before you blame the splats.

A practical note: inverting a pose does not commute with your expectations about which direction is "forward." The pack uses the OpenCV camera convention (+X right, +Y down, +Z forward), so after inversion the translation signs flip in exactly the way that makes the node's output look "backwards" to your intuition if you're used to Blender-style Z-up coordinates. That's normal; wire it in and evaluate the render.

Like TrajectoryCompose, this is pure tensor math with zero heavy dependencies - no models, no downloads, runs on anything the pack is installed on. Install the pack via ComfyUI Manager (search camera-comfyUI, Install, restart), or by hand:

git clone https://github.com/Alexankharin/camera-comfyUI.git custom_nodes/camera-comfyUI
cd custom_nodes/camera-comfyUI && python install.py

It's a utility node, the kind you'll wire in for five minutes and never think about again. But when the alternative is hand-inverting matrices in a Primitive node, those five minutes are very well spent.

CategoryCamera/Pose

Inputs (1)

NameTypeDefaultDescription
trajectoryTENSOR

Outputs (1)

NameTypeDescription
trajectoryTENSOR