Since unity has only a 4x4 matrix, today is going to do a 2x2 matrix rotation and actually forget the order. So write down as a template record.
Order:
The following is the C # code that you use to rotate it:
Public structposition{ Public intX; Public intY; Public Override stringToString () {return "X:"+ X +"Y:"+Y;}}voidOnenable ()//Execute{ varPosition =NewPosition () {X =1, Y =0 }; varAnchor =NewPosition () {X =0, Y =0 }; Debug.Log ("Position:"+ position);//print position:x: 1 y:0Position = Rotation ( -, position, anchor); Debug.Log ("position rot:"+ position);//Print position rot:x: 0 y:1}position Rotation (floatRotvalue, Position Pos, Position anchor) { varmatrix00 = Mathf.cos (Rotvalue *Mathf.deg2rad); varmatrix01 =-mathf.sin (Rotvalue *Mathf.deg2rad); varmatrix10 = Mathf.sin (Rotvalue *Mathf.deg2rad); varmatrix11 = Mathf.cos (Rotvalue *Mathf.deg2rad); varx = (float) Pos. Xanchor. X vary = (float) Pos. Yanchor. Y varRx = matrix00 * x + matrix01 *y; varry = matrix10 * x + matrix11 *y; X= Anchor. X +Rx; Y= Anchor. Y +ry; varIntX =mathf.roundtoint (x); varInty =mathf.roundtoint (y); return NewPosition () {X = IntX, Y =inty};}
2x2 Matrix multiplication Template