Hi Maia
You cannot directly use a matrix to transform a mesh, as Scalismo works on a higher level of abstraction. But you can easily construct a transformation from a matrix like this::
def homogeneousTransform(matrix4x4 : DenseMatrix[Double]) : Transformation[_3D] = {
Transformation{
(point : Point[_3D]) => {
val pointInHomogeneousCoords = DenseVector(point.x, point.y, point.z, 1.0)
val transformedPointHomogeneousCoords = matrix4x4 * pointInHomogeneousCoords
Point3D(transformedPointHomogeneousCoords(0), transformedPointHomogeneousCoords(1), transformedPointHomogeneousCoords(2))
}
}
}
val mat : DenseMatrix[Double] = ??? // 4x4 matrix with transformation
val transformation = homogeneousTransform(mat)
val mesh : TriangleMesh[_3D] = ???
val transformedMesh = mesh.transform(transformation)
The more direct would be to specify a transformation directly, using the known rotation (Euler angles) and translation parameters:
val t = RotationAfterTranslation3D(translation = Translation(EuclideanVector3D(1, 1, 1)),
rotation = Rotation(0, 0, 0, center = Point3D(0, 0, 0)))
Best regards,
Marcel