Search
 
SCRIPT & CODE EXAMPLE
 

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]
Comment

PREVIOUS NEXT
Code Example
Python :: Simple dictionary in Python 
Python :: app is not a registered namespace django 
Python :: change django administration text 
Python :: Game of Piles Version 2 
Python :: python to executable windows 
Python :: string to tuple python 
Python :: how to push item to array python 
Python :: string remove in python 
Python :: copy files to a directory using text file 
Python :: How to join train and Test dataset in python 
Python :: dataframe to dictionary using index as key 
Python :: loop indexing 
Python :: print inline output in python 
Python :: make button bigger tkinter with grid 
Python :: Active Voice Python 
Python :: insert data in django models 
Python :: python formdata requests 
Python :: how to delete an item from a list python 
Python :: euclidean algorithm recursive python 
Python :: Python string to var 
Python :: find all regex matches python 
Python :: python dunder 
Python :: how to get key value in nested dictionary python 
Python :: string slices 
Python :: python comment 
Python :: how to create an array in python 
Python :: python planet list 
Python :: get names of all file in a folder using python 
Python :: Python Tkinter Message Widget 
Python :: entropy formula pyhon 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =