View Full Version : Unit-Length Vectors???
lehthanis 07-04-2008, 12:48 AM Does anyone know what a unit-length vector is? Here's the context:
ANIM_rotate <x> <y> <z> <r1> <r2> <v1> <v2> <dataref>
This defines a rotation command. X, Y and Z define an axis of rotation - they should form a unit-length vector. r1 and r2 represent the angle of counterclockwise rotation when the dataref is at its minimum and maximum values respectively, when looking down at the 'arrow' of the vector. (So if the vector is 0,1,0 then a positive rotation is counterclockwise when viewed from above.). v1 and v2 are the minimum and maximum dataref values for calibration purposes. Dataref is the string name of a sim dataref.
I'm going to need to script-enforce that...
|
|
It is a vector that is one unit in length. eg; fromt [0,0,0] to [1,0,0] is one unit in length.
You might want to invest in a couple of DVD's from CG academy. Bobo did one on understanding matrices, vectors and the likes.
RobGalanakis
07-04-2008, 02:26 AM
http://tech-artists.org/wiki/index.php/Unit_Vector
Early peek at the site.
erilaz
07-04-2008, 02:55 AM
Bobo did one on understanding matrices, vectors and the likes.
Which is awesome. :D
LoneRobot
07-04-2008, 10:01 AM
Which is awesome. :D
ditto! still trying to get my head round it all though!
lehthanis
07-08-2008, 04:48 PM
Ok...I understand how to calculate a vector and how to generate a normalized vector from two points.
What if I have a single point helper...and I want to calculate the normalized (unit-length?) vector of the positive z axis...(or any specific axis)...If the point helper is at 0,0,0 and not rotated and I want the normalized vector of the positive z axis...I know it would be 0,0,1. But, if I rotate it a bit and want to calculate the unit length vector of the positive z axis...would I have to already have a vector on the z axis to calculate from or is there a quick and easy command that can pull a vector from an axis?
RobGalanakis
07-08-2008, 05:00 PM
.transform.row3, I think.
lehthanis
07-08-2008, 05:08 PM
Thats brilliant!!! Thanks!
With this I can have them use one point helper for multiple rotation axis...they just select which axis to rotate around...
LoneRobot
07-08-2008, 05:09 PM
i'm thinking you could also use the direction property to get the z axis and calculate a vector from it. is that correct?
v1 = $.pos - $.dir
vect = normalize v1
lehthanis
07-08-2008, 06:03 PM
i'm thinking you could also use the direction property to get the z axis and calculate a vector from it. is that correct?
v1 = $.pos - $.dir
vect = normalize v1
It appears the .dir property is already a normalized row3...
if I place a point helper so that its in its normal state in world space (no world transform rotation) and I do a .dir on it I get 0,0,1
if I rotate it a bit along the x axis I get the same for
selection[1].dir
selection[1].transform.row3
its already normalized I think.
Of course...if I want them to specify which axis to rotate around I'll still have to do a row1, 2 or 3 call I think.
LoneRobot
07-08-2008, 08:06 PM
Hi Robbie,
i was thinking about this on my train ride home and realized my logic had developed a skewed transform matrix. The dir property is a 3d vector, and yes, you are correct, it is normalized.
lehthanis
07-08-2008, 09:10 PM
I've got it working and BOY does it make me happy to see these animations coming together in the sim.
I decided to go with the .transform.row1 or row2 or row3 property...mainly because I'm giving the user the ability to specify which axis to rotate along.
I thought about it a long while and decided on that because for example, a flight stick has one pivot, but rotates on two axes...z axis for roll (positive z is forward on the aircraft), and x axis for pitch. So I can add two modifiers to the stick and specify the same pivot helper for both of those modifiers using different parameters (to include which axis vector to rotate along)
It works as long as I START arranging the pivot with the Z axis pointing forwards (X -90)
lehthanis
08-01-2008, 04:46 AM
Ok...I found out that the vector thing can be reversed...but I'm not sure how to reverse it.
If normalize object.transform.row3 is the normalized vector of the positive z axis of an object...whats the equivalent of the negative z axis? I'm kinda confused on this bit still.
Ok...I found out that the vector thing can be reversed...but I'm not sure how to reverse it.
If normalize object.transform.row3 is the normalized vector of the positive z axis of an object...whats the equivalent of the negative z axis? I'm kinda confused on this bit still.
Just add a negative sign!
a = normalize [1,2,3] --some normal vector
b = -a --the inverse of the same vector, pointing in the opposite direction.
In your case, if $.transform.row3 is the positive Z axis, -$.transform.row3 is the negative Z axis.
lehthanis
08-01-2008, 12:44 PM
Thats like wayyyy too easy an answer bobo...WAYYY too easy...
I was looking for how to do that earlier with regular numbers and now I know. Thanks.
CGTalk Moderation
08-01-2008, 12:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.