Support mathutils.Vector.rotate for 2D vectors #73301
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#73301
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 970/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.08
Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash:
blender/blender@f1aa4d18d4
Worked: (optional)
Short description of error
Yet it is possible to rotate a 2D vector by a Matrix.Rotation
it cannot be done through mathutils.Vector.rotate
Exact steps for others to reproduce the error
// this works
v = Vector((1.0, 0.5))
m = Matrix.Rotation(radians(90), 2, 'X')
result = v @ m
// this will raise a ValueError: matrix must have minimum 3x3 dimensions
v = Vector((1.0, 0.5))
result = v.rotate(Matrix.Rotation(radians(90), 2, 'X'))
Added subscriber: @lobnico
mathutils.Vector.rotate callback TypeCheck fails on 2D vectorsto python mathutils.Vector.rotate callback TypeCheck fails on 2D vectorspython mathutils.Vector.rotate callback TypeCheck fails on 2D vectorsto Support mathutils.Vector.rotate for 2D vectorsChanged status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @ideasman42
Marked this as a TODO for the Python module.
Added subscriber: @laurelkeys
Hey @ideasman42 ,
I've just compiled Blender yesterday and started looking into this issue since it seemed like a good first contribution.
I noticed that on
Vector_rotate
(atsource\blender\python\mathutils\mathutils_Vector.c:1283
) there's a check for only allowing vectors with size 3 or 4.However, the error that's raised comes from an earlier call to
mathutils_any_to_rotmat
, done right before the vector size check.I added a "special case" check for when the vector has size = 2 and the matrix is 2x2 right before it.
I thought this would be better than changing
mathutils_any_to_rotmat
, as it'd need to resize the matrix to be 3x3 (or we'd have to create a new function to return 2x2 matrices).Also, we'd also have to deal with Quaternions and Eulers, and imo using them to rotate 2D vectors should result in an error, since it's not an operation as "well defined" as with a 2x2 matrix.
If you think there's a better approach I'm happy to make the changes. Otherwise, can I create a Diff?
Cheers,
Tiago.
p.s.:
I noticed that
v.rotate(m)
is equivalent tom @ v
, so when testing @lobnico 's examplev.rotate(Matrix.Rotation(radians(90), 2, 'X'))
will be different fromv @ m
.Btw, this would be equivalent to a rotation of v along the Z axis, if we had made it a 3D vector by adding a Z component equal to 0.
fix-#73301.diff
Changed status from 'Confirmed' to: 'Resolved'
Committed blender/blender@bc86eb1780
Added subscriber: @JacobMerrill-1
<3