Author Topic: Convert a vector to axis  (Read 710 times)

Alright, I must say I'm not fully clear on what I'm talking about right now, but here goes:
I'm trying to figure out how to use setTransform to get an object to look at another object. This is server-sided of course. So I understand transforms are set through axis angles, and I understand you can convert between Euler and axis. So what I'm wondering most basically is how to do this, as I can easily get a vector between the two objects, but can I convert from a vector to an axis angle?
Also, while I'm asking questions, what exactly are matrices for, and how can they be applied?
« Last Edit: March 13, 2011, 09:41:48 PM by lilboarder32 »

It's stickied in this section: http://forum.blockland.us/index.php?topic=27230.0

OK, so basically a matrix or matrices plural is a spreadsheet (or a table) of points or data. They're typically used for geometry in programming. Specifically for rotating a vertex, polygon, object, etc.

So for example
Code: [Select]
[0][0][0]
[0][0][0]
[0][0][0]
That's a 3x3 matrix. (with every row and column having the value of 0)

3d rotation matrices usually look like this:

These are using an axis rotation.

To be honest I'm not too sure how they work in Torque (and in anything, I only just started working with them this year). From what I can see from brown townysing the inbuilt functions (MatrixCreate, MatrixCreateFromEuler, type Matrix in the console and press tab to see the rest) they are 7 dimensional string.

So for example, MatrixCreate(%pos,%rot) where
Code: [Select]
%pos = "10 10 10"; //10 on the x axis, 10 on the y, 10 on the z
%rot = "0 0 90"; //0 rot on the x, 0 rot on the y, 90 rot on the z
results in:
Code: [Select]
10 10 10 0 0 90 0

But I'm sure Torque is lying about its suggestion that the rotation should be a 3d vector. So I'm going to guess that it should be an axis rotation.
MatrixCreate("10 10 10",eulerToAxis("0 0 90"))
Code: [Select]
10 10 10 0 0 -1 0.0274156
This looks more right.
So it's only right that the matrix would look something like this (I think...)
Code: [Select]
[10][10][10             ]
[10][0  ][0               ]
[10][-1 ][0.0274156]



But to be honest I have no idea how that turns into 7 word string. If someone else could explain this more thoroughly that would be great.

Thanks Zack, that cleared up some. Although, as you said yourself, that leaves some confusion left.

Thanks Zack, that cleared up some. Although, as you said yourself, that leaves some confusion left.
OK, I found out. It's "PosX PosY PosZ RotX RotY RotZ theta".

OK, I found out. It's "PosX PosY PosZ RotX RotY RotZ theta".
Okay, so that helps me understand matrices and axis angles more, thanks. Are vectors measured in Euler angles?

-mathsnip-

blarg we are gonna be doing this crap in calculus soon, and I thought matricies were complicated enough without variables in them.

ever tried solving a matrix like so:

[a b c | d]
[e f g | h]
[i  j k |  l]

where you try to solve it for

[1 0 0 | M]
[0 1 0 | N]
[0 0 1 | O]

I had to do that during algrebra 2 and that was annoying as heck.
And I got it wrong :c
[/offtopicattempttobegoodatmathlikethecoolbros]

where you try to solve it for
What do you mean by this? I just started matrices and it's easy as stuff.

He's remembering how to solve for three variables with three equations using matrices.