Blockland Forums > Modification Help

Convert a vector to axis

Pages: (1/2) > >>

lilboarder32:

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?

Destiny/Zack0Wack0:

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: ---[0][0][0]
[0][0][0]
[0][0][0]

--- End code ---
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: ---%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

--- End code ---
results in:

--- Code: ---10 10 10 0 0 90 0

--- End code ---

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: ---10 10 10 0 0 -1 0.0274156

--- End code ---
This looks more right.
So it's only right that the matrix would look something like this (I think...)

--- Code: ---[10][10][10             ]
[10][0  ][0               ]
[10][-1 ][0.0274156]

--- End code ---



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.


lilboarder32:

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

Destiny/Zack0Wack0:


--- Quote from: lilboarder32 on March 14, 2011, 02:43:27 PM ---Thanks Zack, that cleared up some. Although, as you said yourself, that leaves some confusion left.

--- End quote ---
OK, I found out. It's "PosX PosY PosZ RotX RotY RotZ theta".

lilboarder32:


--- Quote from: Destiny/Zack0Wack0 on March 15, 2011, 02:38:51 AM ---OK, I found out. It's "PosX PosY PosZ RotX RotY RotZ theta".

--- End quote ---
Okay, so that helps me understand matrices and axis angles more, thanks. Are vectors measured in Euler angles?

Pages: (1/2) > >>

Go to full version