dimforge / dimforge/nalgebra

Isometry, Similarity, Quaternion look_at_rh/lh are confusing

Open
#227 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Although lookAt is usually accepted in computer graphics as view matrix lookAt since this functions are part of objects that in principle express model transformations one would expect that calling look_at_* on them would orient the transformation so an object transformed by it would look at the passed parameters not a view or camera transformation.

For example calling:

```
let iso = Isometry3::look_at_rh(&pos, &target, &up);
iso.append_rotation_mut(rot);
```

the isometry is initialy generated as a camera or view matrix but the appended rotation is a model rotation so it doesn't make much sense, the look_at doesn't work for orienting a model and append_rotation wouldn't work either for rotating a camera view that was created with the `look_at_rh` method.

Having look_at as a model transformation the previous code would make sense, if applied to a camera one just needs to get the inverse which is really what look_at_rh is doing internally but the later rotation would also work rotating the camera (or any other object).

perhaps to disambiguate the function could be called `look_at_model_rh` and then have something in the top namespace that directly generates a lookAt matrix, perhaps `na::look_at_rh/lh()`?

That way if one is programming a moving camera the methods can be used as:

```
let iso = Isometry3::look_at_model_rh(&pos, &target, &up);
iso.append_rotation_mut(rot);
let view = iso.inverse().matrix();
```

To make an object look at another:

```
let iso = Isometry3::look_at_model_rh(&pos, &target, &up);
iso.append_rotation_mut(rot);
let model = iso.matrix();
```

or for more simple cases where someone just needs a simple lookAt view matrix:

```
let view = na::look_at_rh(&pos, &target, &up);
```

I know that `new_observer_frame` already does this just wondering if `look_at_*` really belongs in this objects since it creates a different type of matrix than the rest of methods and it's not compatible with them, at least from a computer graphics point of view,

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.