AnswerBun.com

Rotate vector by matrix?

Game Development Asked on December 29, 2021

If I have a Vector, say (1,1), how can I rotate it around the origin (0,0)?

I’m working in XNA if that helps.

2 Answers

Since you are using XNA, there is an easy way to do the above, which can be found in this following thread. In shows how to perform the transformation in 3D or 2D. For 2D, it is as simple as:

point = Vector2.Transform(point, Matrix.CreateRotationZ(AngleToRotate);
point += originPoint;

Note that AngleToRotate is in radians. If you want to use Degrees you can can take advantage of

MathHelper.ToRadians(float degree)

which is a static method.

Answered by Waleed Al-Balooshi on December 29, 2021

Just multiply the vector by a rotation matrix:

| fx |     | cos a    -sin a | | sx |
| fy |  =  | sin a     cos a | | sy |

where fx and fy are final coordinates of the object after the rotation and sx, sy are starting one. Obviously a is the angle involved.

Answered by Jack on December 29, 2021

Add your own answers!

Related Questions

How to move a character from 1 to 3 squares on a grid?

0  Asked on January 23, 2021 by shunkashuu

     

Unity 2017.3.of3 Raycast2D randomly misses objects

1  Asked on January 15, 2021 by hesitatetowonder

     

How to fix the vibration while colliding?

1  Asked on January 13, 2021

   

Render order in 3/4 view game

0  Asked on January 10, 2021 by chuan-li

 

How can I control ads frequency?

1  Asked on January 10, 2021 by ruslan-plastun

   

Attach movement to each list object

1  Asked on January 9, 2021 by mavish

     

How to make a map surface object

1  Asked on January 8, 2021 by anonymous-entity

     

Coding Spelunky Edge Roll Mechanic

0  Asked on January 5, 2021 by austin-weaver

     

Creating a lookup table of datamaps in Harlowe/Twine

0  Asked on January 4, 2021 by the_e

   

Unity 4 – Some Rigidbodies Won’t Fall Asleep

5  Asked on January 3, 2021 by ryan-berserkguard-nrby

       

Unity PackageCache keeps having errors

0  Asked on December 31, 2020 by christopher-perry

 

Phaser Tiled map importing

1  Asked on December 30, 2020 by kabuto178

     

Change the colour of all particles on screen

1  Asked on December 27, 2020 by super-potato

   

How can you make a jump to a point using the Character Controller?

0  Asked on December 25, 2020 by aimon-z

   

Trouble destroying an SDL2 texture from another class

1  Asked on December 21, 2020 by gamer1

 

How to hide objects behind an invisible plane?

1  Asked on December 18, 2020 by hatinacat2000

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir