Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to rotate the 2D vector by degree in Python:

from math import cos, sin

import numpy as np

theta = np.deg2rad(30)

rot = np.array([[cos(theta), -sin(theta)], [sin(theta), cos(theta)]])

v = np.array([1, 0])
w = np.array([3, 4])

v2 = np.dot(rot, v)
w2 = np.dot(rot, w)

print(v2)  # [0.8660254 0.5      ]
print(w2)  # [0.59807621 4.96410162]
Source by www.atqed.com #
 
PREVIOUS NEXT
Tagged: #How #rotate #vector #degree
ADD COMMENT
Topic
Name
7+1 =