Without parenting, how do you rotate an object around an origin in python?

I need to rotate an object around an “origin” that is not an object but only a vector. Do i need matrix transformation or something mathematical involving to do this?(I’m hopeless at math)

If you wanna use degrees yes. But blender has a math lib with functions to do the conversion so don"t worry.

You can rotate the vector if you have a target rotation in matrix form, like a worldOrientation. Or you can go full matrix. I’ll post an example tonight…

Here’s how to do it with matrix transforms:
mat_transforms.blend (454 KB)


import mathutils
import math
import bge

# you can implement you own turning
TURN = mathutils.Matrix.Rotation(math.radians(1.0), 4, 'Z') 

def turn(controller):
    owner = controller.owner
    turnAroundPoint(owner, getCenterPoint(), TURN)
def turnAroundPoint(object, centerPoint, turnMatrix):
    Applies the transformation to turn the given 
    object around the given center point by the
    given turn once. For an animation run that at each frame.
    translation = mathutils.Matrix.Translation(centerPoint)
    object.worldTransform = (
        translation *                # move to center
        turnMatrix *                 # turn around origin (0,0,0)
        translation.inverted() *     # move back 
        object.worldTransform )      # apply previous modification

def getCenterPoint():
    Taken from actuator 
    You can implement your own version 
    of finding the center point
    return getActuatorsObject().worldPosition

def getActuatorsObject():
    ''' Q&D: return the object of the first actuator e.g. from a TrackTo. '''
    return bge.logic.getCurrentController().actuators[0].object

Always [True Level Triggering enabled]
–> Python “transform.turn”
-----> editObjectActuator in TrackToMode and set object field

Thanks for the great help guys, feels like this could take a LONG while for me to digest, probably need to dive back into khan academy to learn how to do matrix for real this time