question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change the behavior or name of Matrix.getInverse() to align with the rest of the API

See original GitHub issue

Is your feature request related to a problem? Please describe.

At any other place in the API I’ve seen so far, the semantics of methods are <source>.getSomething(<target>). Except for Matrix.getInverse where this becomes <target>.getInverse(<source>). I find this extremely confusing and it can expose developers to some nasty bugs. It is true that the docs do clarify this, however it goes against some natural assumptions you make as a programmer. You assume that the API is consistent, and you assume that a getter gets a property or derived value of the this object, and not the parameter.

Describe the solution you’d like

Either change the semantics of the getInverse function to apply the inverse of this to the parameter matrix, or change the name to setToInverseOf().

For reference, in Babylon this is much more clearly named: https://doc.babylonjs.com/api/classes/babylon.matrix#inverttoref

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
mrdoobcommented, Nov 2, 2020

I don’t like either way to be honest.

I like this pattern better:

matrixInv.copy( matrix ).invert();
3reactions
AndrewPrifercommented, Oct 27, 2020

@RemusMar it’s this way for performance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Raycast in Three.js with only a projection matrix - Stack Overflow
Raycaster: Unsupported camera type. I can change from a generic THREE.Camera to a THREE.PerspectiveCamera without affecting the rendering of the ...
Read more >
Align diagonals of a labelled matrix with diagonal dots - TeX
I propose this solution, with smaller labels and a width equal to the width of –1: \documentclass{article} \usepackage{blkarray} ...
Read more >
FRotator | Unreal Engine Documentation
Implements a container for rotation information. All rotation values are stored in degrees. Variables. Name, Description.
Read more >
Matrix4 – three.js docs
The most common use of a 4x4 matrix in 3D computer graphics is as a Transformation Matrix. For an introduction to transformation matrices...
Read more >
Chapter 3 Registration - Insight Toolkit
Registration is treated as an optimization problem with the goal of finding the spatial mapping that will bring the moving image into alignment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found