Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how we can use CoordinateTransformations #53

Open
VEZY opened this issue May 15, 2024 · 2 comments
Open

Document how we can use CoordinateTransformations #53

VEZY opened this issue May 15, 2024 · 2 comments

Comments

@VEZY
Copy link
Owner

VEZY commented May 15, 2024

We are in the process of using the transformations from Meshes directly, but it means the package will not be compatible with CoordinateTransformations out-of-the-box anymore. Document how we can use such transformations instead.

The issue comes from the fact that we apply the transformation on the points directly, in the apply_transformation internal function:

function apply_transformation(transformation, ref_mesh)
    Meshes.SimpleMesh([transformation(p) for p in ref_mesh.vertices], Meshes.topology(ref_mesh))
end

The thing is CoordinateTransformations does not know how to be applied over Meshes.Point3, so we need to operate the transformation on the coordinates of the points instead, like so:

function apply_transformation(transformation, ref_mesh)
    Meshes.SimpleMesh([transformation(p.coords) for p in ref_mesh.vertices], Meshes.topology(ref_mesh))
end

But we can't apply the transformation from Meshes like so (don't know why, but the results are wrong, I don't have the time to investigate more).

So the solution is to keep applying the transformation on the points, but ask users to adapt a little bit the CoordinateTransformations transformation to manage Points. For example, to apply a rotation and a translation over a point, we can ask to wrap the transformation in a function and return a Meshes.Point like so:

mat = randn(4, 4)
transformation = x -> Meshes.Point3((Translation(@view mat[1:3, 4])  LinearMap(@view mat[1:3, 1:3]))(x.coords))

And then we can use the transformation directly on a Meshes point:

transformation(Meshes.Point3(1, 2, 3))
@VEZY
Copy link
Owner Author

VEZY commented May 16, 2024

Added doc to geometry for that

@VEZY
Copy link
Owner Author

VEZY commented May 21, 2024

Update: the geometry only accepts Transformations from TransformsBase / Meshes now, so we need to set a wrapper Transformation around the CoordinateTransformation.jl ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant