Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / 3D math help

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 6th Jun 2013 23:38 Edited at: 6th Jun 2013 23:40
Here's the problem.

Let the vector space V be the Euclidean space R3. Consider the vectors e1 = (1,0,0), e2 = (0,1,0) and e3 = (0,0,1). Then any vector in R3 is a linear combination of e1, e2 and e3.

Let vector d be an arbitrary directional unit vector in R3 (unit vector -> length = 1)
Let vector a be an arbitrary vector in R3 (length = anything).

Vector d represents a rotation with it's origin being vector e3. Therefore, the angle and axis of this rotation can be calculated:

angle = dot(e3,d) / (length(e3)*length(d))
which simplifies to: angle = d.z/length(d)

Vector d is equal to e3 rotated around axis cross(d,e3) by angle.

Rotate vector a around vector cross(d,e3) by "angle" and calculate the resulting vector a'.

Here's an image I drew in paint, illustrating the problem graphically:


EDIT: Vector d is actually a unit vector. I drew it wrong.

Any help?

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 6th Jun 2013 23:47
I don't fully understand the problem but I think you're trying to figure out how to determine a new point given an original point, an angle, and an axis of rotation?

Well, I guess the first thing I'd do is calculate the distance of the original point from the origin, as the new point will be the same distance as well. Although it looks like you already have that as you're using vectors, so that's dandy. Next, I guess I'd use magic to break the angle up into 3 angles on the 3 different axis, and then rotate the point around each axis by the appropriate angle to give the new point.

As to how to break that one angle up into 3? No clue.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jun 2013 23:57
Umm, what's the question?

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Jun 2013 00:10
Quote: "Umm, what's the question?"


Rotate a vector around a vector. Pretty much what dbd said:

Quote: "I don't fully understand the problem but I think you're trying to figure out how to determine a new point given an original point, an angle, and an axis of rotation?"


Or this:

Quote: "Rotate vector a around vector cross(d,e3) by "angle" and calculate the resulting vector a'."


I've come up with a solution using two rotation matrices, but it's being screwy. Is there a way without having to calculate the angles and everything?

TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Jun 2013 00:27
The solution I have with rotation matrices kind of works. It glitches when an angle greater than 180° or smaller than 0° is returned, though.

This is the relevant code:



These are my notes:



TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 7th Jun 2013 01:56
Hello
Maybe a matrix like this
http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/

(P 6.2)

It's like the
Build rotation axis matrix4 command..

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th Jun 2013 17:26
xD So fine I'll bite, basically the article Le Verdier posted has it. If you want to know how the matrix works:

The article does a kinda neat trick. In Mathematica form, the matrix Txz looks like this:


(where, each {a,b,c} block is a row)
with the neat property that it's a rotation, and if you right-multiply it by the vector {u,v,w} (column vector), you get {Sqrt[u^2+v^2],0,w}. Meaning, you pull the vector {u,v,w} down on to the xz plane, and it's a rotation, so if you plug in some other arbitrary {x,y,z} vector, it gets rotated, "as you would expect".

Then, once you have the vector in the xz plane, you move it so that it's just on the positive z axis, which looks like this:

with the properties that it's a rotation, and if you right multiply the column vector {Sqrt[u^2+v^2],0,w} to it (which is the result of the previous calculation), you get {0,0,Sqrt[u^2+v^2+w^2]} with s being some number which we don't really care about.

So since those are both rotations they have the properties we want, we can do those transformations, THEN rotate the vector around the z-axis, THEN apply the inverse transformations, to drag the z axis back to the place it was before.

to rotate something about the z axis is just:



Putting it all together: First apply txz, then tz, then r, then the inverse of tz, then the inverse of txz.



Pretty ugly in text form (the matrix in 5.1 in the link), but that's the most useful for plugging it into a program. So anyways that one doesn't depend on the length of (u,v,w), so if that vector is A, you can just say A=d x e3, take R(A,q) (where I mean R is the rotation matrix found in the last code snippet, with (u,v,w)=A).
You just say, a'=R(A,q).a, with the . being matrix multiplication.


"I <3 u 2 bbz" - Dark Frager

Login to post a reply

Server time is: 2026-07-05 18:53:00
Your offset time is: 2026-07-05 18:53:00