본문 바로가기
Deep learning/영상처리

rotation matrix python 회전 행렬 변환 구현

by min0114 2023. 11. 7.

rotation matrix python 회전 행렬 변환 구현


def calc_rotate( x,y,degree=45):
    rad = degree * (math.pi / 180.0)
    nx = round(math.cos(rad) * x - math.sin(rad) * y)
    ny = round(math.sin(rad) * x + math.cos(rad) * y)
    return  nx, ny
    
    
def Ccalc_rotate( x,y,img_cx,img_cy,theta=45):

    new_x = (x - img_cx ) * cos(radians(360-theta)) - (y - img_cy) * sin(radians(360-theta)) + img_cx
    new_y = (x - img_cx) * sin(radians(360-theta)) + (y - img_cy) * cos(radians(360-theta)) + img_cy
    return  int(new_x), int(new_y)

 

반응형

댓글