Enhancement: Initialize SE3 matrix with look_at() function
@petercorke ya está trabajando en esto.
Desde el 31/1/2022.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Feature description
I was wondering if it would make sense to add a look_at() function for this library for initializing an SE3 transformation matrix. I personally use this when positioning a camera etc. where I want the camera at an exact position, look at a specific point, and define which axis is up. This makes defining the pose of the camera very easy. I use an implementation of this function in mitsuba2, where the parameters are
- origin: defines the translation part of the matrix
- target: the target point the z-axis should point towards
- up: the direction which is perpendicular with the x-axis of the transform and the direction of the vector from the origin to the target
Examples
Below are a couple of examples of how the function works in Mitsuba2
Example 1
T = look_at(origin=[1,2,3], target=[0,0,0], up=[0,0,1])
print(T)
[[0.894427, -0.358569, -0.267261, 1],
[-0.447214, -0.717137, -0.534522, 2],
[0, 0.597614, -0.801784, 3],
[0, 0, 0, 1]]
Example 2
T = look_at(origin=[0,0,0], target=[3,0,0], up=[0,1,0])
print(T)
[[0, -0, 1, 0],
[0, 1, 0, 0],
[-1, 0, 0, 0],
[0, 0, 0, 1]]
Mitsuba C++ implementation
static Transform look_at(const Point<Float, 3> &origin,
const Point<Float, 3> &target,
const Vector<Float, 3> &up) {
using Vector3 = Vector<Float, 3>;
Vector3 dir = normalize(target - origin);
dir = normalize(dir);
Vector3 left = normalize(cross(up, dir));
Vector3 new_up = cross(dir, left);
Matrix result = Matrix::from_cols(
concat(left, Scalar(0)),
concat(new_up, Scalar(0)),
concat(dir, Scalar(0)),
concat(origin, Scalar(1))
);
Matrix inverse = Matrix::from_rows(
concat(left, Scalar(0)),
concat(new_up, Scalar(0)),
concat(dir, Scalar(0)),
Vector<Float, 4>(0.f, 0.f, 0.f, 1.f)
);
inverse[3] = inverse * concat(-origin, Scalar(1));
return Transform(result, transpose(inverse));
}
Generalization
The Mitsuba implementation only works for pointing the z-axis at a specific direction defined by the direction of the vector between the origin and the target. The up-axis is also predefined to specify a specific axis in the resulting transformation matrix. For generalization of the function, it could make sense to specify which axes should point toward to target, and which axis is up. This will however complicate the function further. One could split the functionality into three functions for example:
SE3.x_look_at(origin, target, up)
SE3.y_look_at(origin, target, up)
SE3.z_look_at(origin, target, up)
Does this makes sense for anyone else, or would it bloat the code and documentation?
- Lenguaje dominante
- Python
- Estrellas
- 641
- Forks
- 102
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 4
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rai-opensource/spatialmath-python
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
rai-opensource/spatialmath-python#32 · 4 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 50/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
-
bug
rai-opensource/spatialmath-python#165 · 2 comentarios · 1 asignado ·
-
Type-check spatialmath Abierto
rai-opensource/spatialmath-python#143 · 8 comentarios · 1 asignado ·
Todos los issues de rai-opensource/spatialmath-python
Issues similares
-
essnmx good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
-
[Feature] 奇物选择添加优先级 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
syfoud/Simulated_Scepter#174 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Giskard-AI/giskard-oss#2840 · 1 comentario ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Abiertoarea: repo bug perceived difficulty: 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
yeti-platform/yeti#1380 ·