Help me please. I want to define the axis of the mesh. For example I have a cylinder (mesh) I click on the cylinder wall, and the program builds a straight line, the axis of the cylinder.
There is nothing automatic that will let you do that.
You can turn on the points of the mesh and extract the ones at the edges of the cylinder walls. Then select the points of one of the caps and run the
Circle command with the
Fitpoints option. That will create a best-fit circle around the end of the cylinder. Do the same at the other end (unless the cylinder is aligned with one of the world axes) and make a center axis through the centers of both circles.
If I understand correctly, the sequence is as follows:
But I would like to write a script for Rninoсeros. I saw in the third-party plug-ins, it’s possible.
Sorry, your method all happened. I want to automate this process or to write the script or make a plug-in in visual studio. You could do a clue. Help me please.
I’m changing the category to scripting and hope that one of the scripters can help you.
Using PCA you can do that, if you sample your curves/objects into points, then calculate covariance matrix the principal eigenvector is the axis (more or less, depends on the sampling). Something like:
points = sample_objects(object) center = center_of_mass(points) covmat = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] for point in points: x = center - point y = center - point z = center - point covmat += x * x covmat += y * y covmat += z * z xy = x * y covmat += xy covmat += xy xz = x * z covmat += xz covmat += xz yz = y * z covmat += yz covmat += yz principal_axis = eigenvector(covmat, 3)
you can use a simple power method to calculate the eigenvector for the matrix. Hope this helps!
Thank direction asked. I’ll do it. On the results I will tell later.