0

Which Math.Net function do I use to rotate a 3d Vector around another 3d Vector (Pivot Point)?

I am using the C# Library Math.Net, mainly because I am not afraid to say that I struggle with complex mathematical concepts. Someone suggested I use Affine Transformation, but there appears to be no class or method that executes this concept/formula. Also the vector class has no Rotate method so that isn't a solution.

Can you suggest what function, method or class I use to achieve this?

sazr
  • 24,984
  • 66
  • 194
  • 362

1 Answers1

0

I don't know Math.Net but normally you build up a 4x4 Matrix and multiply the vector with that matrix. If you want to rotate around another vector you need a matrix that was build in the following way: (Move to pivot point, rotate and move back to origin)

Pseudocode:

matrix = matrix.translation(pivot.x, pivot.y, pivot.z))
matrix *= matrix.rotationAxisAngle(axis, angle))
matrix *= matrix.translation(-pivot.x, -pivot.y, -pivot.z))

Now you can multiply your vector with that matrix:

newVector = yourVector * matrix
bitWorking
  • 12,485
  • 1
  • 32
  • 38