Change pivot point for rotation

Hey there,

i just tried to find anything about changing the pivot point or applying the pivot point inside of a rotation. I am creating a complex mesh and want to rotate some primitives after they have been created, but i want them in a specific position. So now the question, is there a possibility to change the pivot point (well there should be, i just didn’t find it yet…) or might it be possible to directly give a pivot point in another rotation function?

For the moment i am using the bpy.ops.transform.rotate(…) function, but theres no option for the pivot.

Gorn

I thought it would be as simple as creating a transform matrix by multiplying rotation and translation matrices, but I couldn’t get it to work :S

However, the following does work…


import bpy
from mathutils import Matrix, Vector

def Rad(deg):
    return (deg/360)*2*3.14159265359

def RotateAboutPoint(obj, point, axis, angle):

    translation = Vector(point)
    rotation = Matrix.Rotation(Rad(angle), 4, -Vector(axis))
    
    for vert in obj.data.vertices:
        if vert.select:
            vert.co = vert.co-translation
            vert.co = vert.co*rotation
            vert.co = vert.co+translation

obj = bpy.context.object

RotateAboutPoint(obj, (0,5,0), (0,0,1), 45)

Rotation pivot and axis are in object local space. I’ll leave it to you to account for rotation/translation/scaling of the object or parenting, etc.

I’m not entirely sure why the negative of the axis of rotation is required, but to match rotation in the 3d view this appears to be the case. :confused:

Oh yeah… for some reason it needs to be run in object mode, but is capable of moving only vertices that are selected in edit mode. lol

1 Like

there’s a pivot constraint also…

but can you add pivot around a pointin global axis also?

would be even more powerfull

i can give a little script with menu if needed

happy 2.5

The original question referred to creating a complex mesh so I assumed that editing vertices in a mesh in local space would be more appropriate. I may be wrong. It was also much easier to provide a solution that doesn’t have to take into account object rotation and translation and any possible parent translation and rotation. :wink:

I could possibly have a go at it, but don’t feel inspired to do it until I know exactly how useful it will be and what it’s precise intended use would be. Why not use the 3d cursor as a global rotation pivot?

i’m looking for something to do almost that
which rotate around a specific point and also rotate the object around it’s center also

i have to play more with this may be i can find a way here

example placing a rectangle around a circle but also rotating the rectangle to that the base is always tangent to the circle
hope you see what i mean here

the thing is i also need to do this for let say an ellipse or a parabola
so to be able to set the center point where you want independant of the objet is very nice here!

a good example would be to place stones around an arch!

happy 2.5

RickyBlender, are you wanting to script this or just make it in the 3d view? Without a script it should be fairly easy.

Placing a number of rectangles around a circle can be done using the spin duplicate tool.

For the parabola or elipse, you could always try creating a curved path and animating the object along the path then using dupliframes to position the object at frames along the path. I’m not sure if this would give the results you are after though. Not quite sure if you’re talking about objects or a single mesh, but both should be possible with joining and duplicating, I think.

Isn’t this going way out of hand? So you cannot just set the pivot point (or origin) to a world xyz coordinate?

@dalai: Feel free to implement it. :wink:

Setting a rotation pivot is not currently available in the rotate operator:
http://www.blender.org/documentation/250PythonDoc/bpy.ops.transform.html#bpy.ops.transform.rotate

but you can change the location of the center before then reset it after if needed i think!

the thing is i like to prepare a big script over time to make all kind of arches
which have different shapes and be able to add some stones around the arch and not manually cause
if you have an arch with 100 stones around you take the time to add stones manually and tell me how long it takes?LOL

it almost has to be an independant object then after i can reselect and join together
all the stones to form a new object

Note there are 2 ways to make the stones around an arch
square edges or slanted edges
and may have to do the slanting edges before doing the rotation

happy 2.5

If your arch is just a single object without rotation centered on the origin then the above rotation will work, but for positioning vertices it might be better to use some math. There was an arch making script about a while ago. Not sure if it got ported to 2.5x yet or maybe integrated into another script. If you can find this script then the code might be of use to you.

Alternatively, you could have a look at how things are done in the bolt factory addon that comes with Blender. It will most likely use some math to build the bolts.

The equation for an ellipse is essentially:

x^2 = a*y^2

For making other forms such as parabolas, and hyperbolas you could do a little research into conic sections. The conic sections define circles, ellipses, parabolas and hyperbolas. The math is actually pretty simple, but you don’t need to understand it, just use the equations that you can find on the net in your code. :slight_smile:

All architectural arches can be defined mathematically. For example, gothic arches are just two arcs of a circle that intersect at the point. I did a bit of reading about this and it was quite interesting. I found diagrams that show exactly the ratios and spacing of the intersecting circles for different arch types.

already have most of the info on arches after lot’s or research
and i have something like 30 different type of arches already
i don’t really have any problems with the math as such but
i’ was thinking to use this rotation for the arches stones cause it looks simple and fast to do

and i already began doing this in 2.49 but have to port it into 2.5
with 30 arches type it’s gone be a big script very long so not certain when i can do this porting
may be later next spring

right now i’ have to work on another big script for IES data reading and some algo for IES lamps/fixture
which is taking more time cause of all changes in API this summer
so hope there are not too many changes now! LOL

Thanks