Generalize transforms (translation, rotation, scaling) · Issue #1571 · dimforge/nalgebra · GitHub
Skip to content

Generalize transforms (translation, rotation, scaling) #1571

Open

Description

@Caellian

There's room left for generalization with respect to dimensionality when it comes to transforms in nalgebra.

Most:

Some of these are relatively easy to generalize. Some are not that useful (like projections), but it would be cool to have code that just works no matter the dimension. Rotation might be useful for topology and scientific applications (beyond just rendering) - implementing this and generalizing Transform was the main motivator for opening this issues.

However, I don't personally need this right now. I just wanted to propose this as I don't see any good alternatives.

Activity

  1. Caellian commented on Nov 5, 2025

    @Caellian
    Author

    Orthographic projection formula from Wikipedia:

    $$ P = ST = \begin{bmatrix} \frac{2}{\text{max}_x-\text{min}_x} & 0 & 0 & 0 \\ 0 & \frac{2}{\text{max}_y-\text{min}_y} & 0 & 0 \\ 0 & 0 & \frac{2}{\text{max}_z-\text{min}_z} & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & -\frac{\text{min}_x+\text{min}_x}{2} \\ 0 & 1 & 0 & -\frac{\text{min}_y+\text{max}_y}{2} \\ 0 & 0 & -1 & -\frac{\text{min}_z+\text{max}_z}{2} \\ 0 & 0 & 0 & 1 \end{bmatrix} $$

    This is easily generalized for arbitrary slicing planes. z-axis (self.matrix[(2, 2)]) is flipped because camera looks towards -Z in graphics APIs, though correctness of that depends on use case I guess.

  2. Caellian commented on Nov 6, 2025

    @Caellian
    Author

    Related to PR #1366.

  3. muzammil35 commented on Nov 27, 2025

    @muzammil35

    Can I give this issue a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions