You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently developing a geometric application that utilizes 3D Zernike Moments to identify similar shapes. While these moments are designed to be rotationally invariant, I have observed an issue after applying the following transformation using OCC:
It appears that the vertex distribution changes after this transformation. This was confirmed by observing differences in the principal axes between the original and rotated models. It's also worth noting, that using freeCAD to rotate the model, then import it via OCC and perform PCA results in receiving the same axes in the rotated and non-rotated case.
Here is the code used to extract vertices and align the model to its principal axes:
defgetVertices(shape):
ifnotisinstance(shape, TopoDS_Shape):
raiseTypeError("The provided shape is not a valid TopoDS_Shape")
vertices= []
explorer=TopExp_Explorer(shape, TopAbs_VERTEX)
whileexplorer.More():
vertex=topods.Vertex(explorer.Current())
pnt=BRep_Tool.Pnt(vertex)
vertices.append([pnt.X(), pnt.Y(), pnt.Z()])
explorer.Next()
returnnp.array(vertices)
defalignModelToPrincipalAxes(shape, use_sklearn=True):
""" Align the model to its principal axes using PCA. """vertices=getVertices(shape)
# Center the vertices around the origincentroid=np.mean(vertices, axis=0)
centered_vertices=vertices-centroid# Normalize the verticesmax_distance=np.max(np.linalg.norm(centered_vertices, axis=1))
normalized_vertices=centered_vertices/max_distanceifuse_sklearn:
pca=PCA()
pca.fit(normalized_vertices)
principal_axes=pca.components_.T
I am trying to understand why the applied rotation alters the symmetry axes and consequently the vertex distribution. Any insights or suggestions on this matter would be greatly appreciated.
Thank you.
The text was updated successfully, but these errors were encountered:
Hello,
I am currently developing a geometric application that utilizes 3D Zernike Moments to identify similar shapes. While these moments are designed to be rotationally invariant, I have observed an issue after applying the following transformation using OCC:
It appears that the vertex distribution changes after this transformation. This was confirmed by observing differences in the principal axes between the original and rotated models. It's also worth noting, that using freeCAD to rotate the model, then import it via OCC and perform PCA results in receiving the same axes in the rotated and non-rotated case.
Here is the code used to extract vertices and align the model to its principal axes:
I am trying to understand why the applied rotation alters the symmetry axes and consequently the vertex distribution. Any insights or suggestions on this matter would be greatly appreciated.
Thank you.
The text was updated successfully, but these errors were encountered: