Closed severin-lemaignan closed 6 months ago
@ayberkozgur : thanks for the review. I've updated the PR with the vertical FOV instead of the horizontal one.
How about adding a little test ? Something minimal would do, just so we stop adding untested code, even trivial...
Then the usual question (you're usually the one asking it, so here is your karma): is this functionality worth the "increased complexity of the api" ? To be the devil advocate: if you don't use raw OpenGL, your framework most likely has a utility to build a projection matrix for you... If not, well, you're not gonna be bothered by one more line to type yourself ;)
I think one float
getter hardly increases the complexity of an API :)
You mean one [method with whose name is an acronym, making non obvious computations on double matrices, and returning a] float, right ? Looks like a boolean coding for horizontal/vertical is complex enough to require a code review ;)
One method is about 10% of the current 3D API. How about a comment in the documentation of getCameraMatrix giving the formula to compute the FOV, as an illustration of what's in the camera matrix?
@qbonnard You're trying to convince the wrong guy, I'm OK with as many API components as needed as long as they are all properly documented :)
The fact that FOV is not something "provided" by Chilitags but is already there is another thing though. The user, in their framework, provides the FOV (and other calibration parameters) to Chilitags and should "know about" them when they're necessary; it should not ask them from Chilitags.
Okay, let's flip side again ;) Following @ayberkozgur 's argument, we should also remove getCamera then, since the user should also know about it... The use case was for calibrations read from a file given to Chilitags, to avoid parsing it again by the user.
Now I'm lost about who thinks what, starting with myself. But I'm happy to see that @severin-lemaignan is a Unity evangelist ;)
Anyway, I wouldn't store the FOV, but rather recompute it on each call to getFOV, because I don't expect the user to query the FOV every frame (and even then, it's no drama), but it removes 4 lines (out of 5 ;) ). Also, you slipped @bhack 's change of the ITERATIVE parameter into your commit, if I'm not wrong... Is that on purpose ?
@qbonnard Ok, replaced 5 lines with a single line + removed the SOLVE_ITERATIVE that actually slipped there.
With a little test, it would be perfect ;) Actually, that would be a good way to evaluate whether a change to the API is worth it: "Is the commiter ready to provide unit tests for it ?" So far, only Filter has some kind of unit test. How about Starting a Chilitags3D unit test (even if it has only getFOV in it for now)...
Useful in particular to rebuild projection matrices in OpenGL for instance.