jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
MIT License
234 stars 40 forks source link

Inverse Matrix in the Demo does not work when scaling #48

Closed Unreal852 closed 3 years ago

Unreal852 commented 3 years ago

Hi, i used the Matrix3 provided in the Demo but when scaling it, the inverse matrix does not work, or maybe i'm doing it wrong . Here is how i update my matrix

Matrix.LoadIdentity();
Matrix.Scale(ViewZoom, ViewZoom);
Matrix.Translate(ViewPosition.X, ViewPosition.Y);
InverseMatrix.CopyFrom(Matrix).Inverse();
jingwood commented 3 years ago

Yes I can confirm the bug, let me fix it...

drewnoakes commented 3 years ago

Could potentially use System.Numerics.Vectors instead.

jingwood commented 3 years ago

Added the scale feature, as well as new feature for drag-to-move. image

Thanks, @drewnoakes! I haven't noticed there is a built-in numeric library. Now It has been changed to use the System.Numeric.* instead.