Create a circle by rotating a 3d point around pivot

Viewed 401

I want to rotate a 3d point and create a circle by using each rotation step. I have only a start point (pos1, 1x3 array) in the hand, which indicates, where the circle should begin. This point should be rotated in an axis in the clockwise direction, without changing the r and create 10 different 3d points around the origin, which are equally distributed on the circle, see image below:

Image

For this, I implement the 2D rotation matrix and rotate my point pos1 in x and y directions with given angle, but it seems it does not create a circle at the end.

def rotate_point(origin, point, angle):
    angle = math.radians(angle % 360)

    rotatedX= origin[0] + (point[0] - origin[0]) * math.cos(angle) - (point[1] - origin[1]) * math.sin(angle)
    rotatedY= origin[1] + (point[0] - origin[0]) * math.sin(angle) + (point[1] - origin[1]) * math.cos(angle)
    return rotatedX, rotatedY

def main():
    origin= np.array([0, 0, 0]) 
    point_to_rotate  = np.array([1.12, 199.32, 1062.88])
    theta = 10

    rotatedPoint= rotate_point(origin, point_to_rotate , theta)
    print('rotatedPoint:', rotatedPoint)

Edit: It does actually, what it should do, if I run it in a for loop, but in counter clockwise.

def main():
    origin= np.array([-1.14, 172.59, 1078.31])
    point_to_rotate  = np.array([1.12, 199.32, 1062.88])
    theta = 0
    for i in range(10):
        theta = theta+36
        rotatedPoint= rotate(origin, point_to_rotate , theta)
        print('i:', i, 'degree: ', theta, 'rotate:', rotatedPoint)

Edit 2: If I not increment the degree but reduce it, then it creates the points in clockwise direction:

theta = 360 

then in for:

theta = theta-36
1 Answers

See edits for the solution of my issue. Here is a circle created based on rotated point.

enter image description here

enter image description here

Related