I have a pistol model whose rotation is a few degrees off:
Does Blender have a function that would automatically fix the rotation and "align" it according to the object's geometry, perhaps like the 3D cursor to Selection option?
Thank you!
I have a pistol model whose rotation is a few degrees off:
Does Blender have a function that would automatically fix the rotation and "align" it according to the object's geometry, perhaps like the 3D cursor to Selection option?
Thank you!
Palkonimo has the basics of it right, but you can accomplish the same thing more quickly using Blender's built in snap options.
Begin by picking two points on your model that you want to line up with an axis. Move the 3D cursor to one of those points.
Duplicate that point, and move it away along the axis you wish to align to.
Select the other of your chosen points on the model as the active element, expand your selection of the model using L or Ctrl +.
Rotate, using vertex snap to active element, and target the vertex you duplicated earlier.
I think there's no way of automatically doing it. Yet would be a nice addition, though you'd still have to select an edge and an axis that ought to be aligned.
Nevertheless, you can do it manually. As you can see in the image, there's a plane rotated a bit. I want to align it "according to it's geometry". This means that I have to select an edge and an axis that I want to align. In my case I want to align the selected edge with the y-axis. And from the drawn triangle we can derive the angle that the plane has to be rotated.
We just need to know the lengths of two of the triangle's sides. Since you know the position of the vertices, which are also two of the corners of the triangle, we can just calculate them:
In my case the length of the red vertical line is the difference between the y-coordinates of the vertices: 0.759317 - (-1.193079) = 1.952396
The length of the red horizontal line is the difference between the x-coordinates of the vertices: -1.193079 - (-0.759317) = -0.433762
Now we just have to use some trigonometry. With a
being the angle we are looking for: a = arctan(-0.433762/1.952396) = -12.525905490885°
In this gif you can see that it is now aligned after rotating it that exact amount:
Now, this is just an example. In your specific case you'd probably choose an edge on the pistol's side and align it to the z-axis. Then do the same math: get the difference of the z-coordinates for one, the difference of the x-coordinates for the other side. Then use the arctan to get the angle and rotate your weapon along the y-axis.