0

Let me preface this by saying i know NOTHING about this kind of maths, so dont feel like you are oversimplifying. I have a directional vector firing out of an object and i need to rotate it by X amount left or right. The co-ordinates range from -1.0 to +1.0 on each axis. up until now i have been treating the maths aspect of this like a black box and have just been using premade functions to deal with it, but now i am totally lost.

Screenshot showing the format of the vector along with some lines showing what i want to do:

img

i am writing this in CPP and only have access to the inbuilt maths functions, no other libraries.

Spektre
  • 49,595
  • 11
  • 110
  • 380
knedit
  • 1
  • 1
  • Welcome to [Euler angles](https://en.wikipedia.org/wiki/Euler_angles). They are not bad. The key is defining your Axis and coordinate systems. (a local coordinate system on the arm, and a world coordinate system the arm moves in) Basically, you will need to translate local coordinates attached to the arm into your program coordinate system (whatever the ground and scenery uses). A movement then becomes a series of rotations in the local frame that can be translated into movements within your program. Github has many euler angle libraries ready to use. – David C. Rankin Apr 03 '21 at 11:48
  • You want to rotate around a vertical axis, right? And perhaps also around a horizontal axis, right? Are you able to work with matrix multiplication? – Ripi2 Apr 03 '21 at 19:26
  • 1
    Euler angles might seem like a simple stuff to implement but it only leads to many confusions and bugs ... I would use matrices instead see [Understanding 4x4 homogenous transform matrices](https://stackoverflow.com/a/28084380/2521214) however you can combine these approaches (and use the Euller angles as the last step just to bound the final rotations) – Spektre Apr 05 '21 at 08:00

0 Answers0