-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hi, sry for bothering with this small issue, but I've found that your implementation of the rotation could be improved:
Your version:
if np.random.uniform() < prob:
angle = np.random.uniform(0, 360)
rotation_matrix = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
data[:,:2] = data[:,:2].dot(rotation_matrix)
Better version:
- convert angle to radians before applying numpy
- Usually you multiply rotation matrix from left side (R * X), thus in your case you should transpose rotation matrix to get same numbers.
This is what you should have after multiplication:
x′=xcos(θ)−ysin(θ)
y′=xsin(θ)+ycos(θ)
if np.random.uniform() < prob:
angle = np.random.uniform(0, 360) / 180 * np.pi
rotation_matrix = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
data[:,:2] = data[:,:2].dot(rotation_matrix.T)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels