# Rodrigues' rotation formula: question about variable K

I know this is more of a mathematical question and not necessarily related to Rust. I'm implementing Rodrigues' rotation formula and I'm a bit confused about what `k` is supposed to be. I know that `v` is (usually) the position, and `theta` is the angle to rotate the vector by, but I'm unsure what to do with `k`. In some usage examples I've seen the normalized cross product of `v` be used, but that can't be the only possible axis I can use. I've also tried the unit vector on the X axis (e.g. (1, 0, 0)).
I'm using the formula to try to raycast in 3D. I suppose I could just use an AABB, but raycasting seems a lot simpler than AABBs.

I know I could just use ncollide/nphysics, but I'd like to implement this on my own to get a better understanding. What am I missing? (The Wikipedia article sadly wasn't very helpful.)

Edit: what I'm trying to do is to acquire the 3D vector given an angle in radians. Though I've found how to do this online in 2D, I'm unsure about the maths to extend it to 3D, and the only way a lot (and I pretty much mean all) of the search results I've tried to find about this point to this formula, or to acquiring the angle of two vectors, which (isn't) what I want to do.

I think the right place to ask this would be the math or computer graphics Stack Exchange.

It's the direction of the axis around which you rotate. You have to decide what direction it is.

1 Like

I understand that but would I use a unit vector (e.g. the forward vector) or can I use any axis vector I want? I'm trying to figure out "sensible" ways of using the formula; I know you can theoretically use any vector you want but that doesn't mean you should because you risk getting erroneous results.
And yes, I'll probably go ask about this on SO as well -- more answers is better, I imagine.

Hi, I'm pretty sure that I do not understand your question, so let my talk about some related stuff.

In 2d you can get a unit vector from an angle.
In 3d you can get a unit vector from a solid angle
Here the reason is, that the collection of all unit vectors in 2d is a circle (or its boundary), which is one dimensional. In 3d, the set of all unit vectors is a 2dimensional sphere.

Upshot: You need two angles to specify a vector in 3d.
For many purposes the best formula to generate unit vectors in 3d is IMO

Does this help? I'm happy to talk about this topic In most formulæ, unless there is explicit normalization, directions are supposed to be represented by unit vectors.

Thanks! This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.