Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: understanding orientation of hooks  (Read 3833 times)

0 Members and 1 Guest are viewing this topic.

just champi

  • Modder
  • member
  • Offline Offline
  • Posts: 607
understanding orientation of hooks
« on: July 25, 2010, 10:09:09 AM »

HI,
Ok, what mean all that bunch of numbers for the hooks in the .msh files?

Let's divide them in two parts, and if you want to give it a name, all this bunch of numbers are Matrix3 values. (not the movie...but a matrix that consist in 4 rows of 3point values)

This is a format that Max uses to store data related to object coordinate systems and transformations. (It's fast to work with and useful for make animations between others things)

As it's already said and known, we have two parts: one stores data about coordinate systems (= orientation) and the other part stores data about transformations (= position)
let's see and example:

[HookLoc]
1 0 0 0 1 0 0 0 1 0.20552 -6.03074 -0.24958

Now let's separate the two groups of data to see them better (remember: 4 rows of 3point values)


    1st row   2nd row   3rd row                  4th row

     1 0 0     0 1 0     0 0 1             0.20552 -6.03074 -0.24958

       (coordinate systems)                    (transformations)

         [orientation]                           [position]

this is the same for every matrix3 values so

0 0.173648 -0.984808 -1 0 0 0 0.984808 0.173648 0.11005 -2.3107 -0.59059


corresponds to:

         1st row              2nd row            3rd row                       4th row

  0 0.173648 -0.984808        -1 0 0         0 0.984808 0.173648       0.11005 -2.3107 -0.59059






In 3ds Max, World Coordinates are setup this way: (imagine yourself in front of your monitor)


   x is positive to your right, and negative to your left

   y is negative at your back and positive in front of you

   z is positive above your head and negative below your feet




As you already know, this is the type of data that corresponds to the second part (the last three numbers) in the example above (transformations):

 So the seconD part is ALWAYS the x, y, z coordinates of a point in WORLD COORDINATES:

    1st row   2nd row  3rd row                  4th row

     1 0 0     0 1 0    0 0 1         0.20552 -6.03074 -0.24958
                                           X        Y        Z        (World Coordinates)

       (coordinate systems)                    (transformations)

         (orientation)                           (position)




So following the anterior example (and getting rid of the last decimals numbers,) we can say that this particular point is located (looking at the monitor)

   0.20 meters to my right (x= positive)

   6 meters  from my back (y= negative)

   0.24 meters below my feet (z= negative)




  And (0,0,0) it's ALWAYS EXACTLY the center of the grid



 

Now the second part (the first 9 numbers):

 
these numbers are coordinates also (but from a particular grid) and they tell us how the local axes on an object are oriented in the espace.


Imagine that we place a small grid centered in the pivot of the object and aligned with the World grid.








That grid doesn't rotate with the object, only moves along with him and always stay aligned with the world grid.

Only will have positive and negative values between 0 and 1, and the lenght of the different axes will be = 1.

And his orientation will be like the one for the world grid (imagine yourself in front of your monitor):


        x will be positive to your right, and negative to your left

   y will be negative at your back and positive in front of you

   z will be positive above your head and negative below your feet





Now we can use our new grid to know and check the coordinates of the Local axes of the object:

 In the end, any axe is a line, and we know that to represent a line we need two points, and 3 coordinates for everyone, so : 1st point(x,y,z) and 2nd point(x,y,z) for every axe. 

This will be:


               X axe                           Y axe                           Z axe

     1point(x,y,z)  2point(x,y,z)   1point(x,y,z)  2point(x,y,z)    1point(x,y,z)  2point(x,y,z)


BUt as the axes are perperdincular one to each other and our particular grid is already centered in the pivot point of the object, the first point always will be (0,0,0) and will be the same  for every one of the axes (it's the origin for them)







so this will be:

                         X axe                 Y axe                 Z axe
     origin(0,0,0)   2point(x,y,z)           2point(x,y,z)        2point(x,y,z)


so we can get rid of the first point and stay only with the other three.

 

                         X axe                  Y axe                Z axe
                        (x,y,z)                (x,y,z)              (x,y,z)

Two one more things:

  * 1- Let's asume that every Local axe has also 1 unit in leght (just like our grid)
  * 2- and let's make the three Local axes macht the orientation of the World grid to begin with (as if the object were not rotated like when we place it in the scene)




 so to draw the three lines corresponding to the three Local axes:

    - we got a line that goes from (0,0,0) to (1,0,0) to represent the X axe



    - a line that goes from (0,0,0) to (0,1,0) to represent the Y axe



    - and a line that goes from (0,0,0) to (0,0,1) to represent the Z axe





let's put all that together in the first example:



    1st row   2nd row  3rd row                                                        4th row

     X axe     Y axe    Z axe

     1 0 0     0 1 0    0 0 1                                              0.20552 -6.03074 -0.24958     

     x y z     x y z    x y z   (in our particular 0-1 grid coordinates)         X        Y        Z        (World Coordinates)

       (coordinate systems)                                                      (transformations)

         [orientation]                                                              [position]




   Let's put in short: the last three numbers are world coordinates of a point, and the first 9 numbers are particular coordinates to "draw" every Local axe at the location of that point.

   and now we can make some asumptions too:

   -The first 9 numbers are always between -1 and 1, because we assign 1 unit in length to our grid and to the Local axes, so if we rotate them, his new coordinates can't be greater than 1 or          lesser than -1, they will always be some positive or negative decimal number in between.

    * When the Local axes match the world axes in orientation (hasn't been rotated) the first 3 rows are ALWAYS 100 010 001 (you'll see that many times).

    * 100 010 001 000 means aligned with World and EXACTLY in the center of the grid.

    * If these first 9 lucky numbers are only ones and zeros other than 100 010 001 means that the object is rotated in multiples of 90 degrees.

   Let's see that with a example:

   0 -1 0     1  0 0    0 0 1 --> means rotated to the right 90º around the Z axe



   * Here we can see also that if the object is rotated only around one axe, the numbers for that axe don't change (as remains aligned with World grid), and his component in the others groups will    be 0.

   Others rotations around the Z axe:
   
   -1 0 0     0 -1 0    0 0 1 --> means rotated 180º around the Z axe (facing backwards) (compare with 100 010 001)


    0 1 0     -1 0 0    0 0 1 --> means rotated to the right 270º (Yaw right) around the Z axe or 90º to the left (Yaw left)(compare with 0 -1 0     1 0 0    0 0 1)


    1 0 0     0  1 0    0 0 1 --> aligned with World (written again to help compare)

        Rotations around the X axe:

     1 0 0    0  1 0    0 0 1  --> aligned with World
     1 0 0    0  0 1    0 -1 0 --> means rotated backwards (pitch up)  90º around the X axe (or 270º pitch down)
     1 0 0    0 -1 0    0 0 -1 --> means rotated upside down 180º around the X axe (compare with 100 010 001)
     1 0 0    0 0 -1    0 1 0  --> means rotated backwards 270º around the X axe or 90º pitch down (compare with 0 -1 0     1 0 0    0 0 1)

        Rotations around the Y axe:

    1 0 0     0  1 0     0 0 1 --> aligned with World
    0 0 1     0  1 0    -1 0 0 --> means roll to the left 90º around the Y axe
   -1 0 0     0  1 0    0 0 -1 --> means rotated upside down 180º around the Y axe (compare with 100 010 001)
    0 0 -1    0  1 0    -1 0 0 --> means roll to the right 90º around the Y axe (or 270º to the left) (compare with 0 -1 0     1 0 0    0 0 1)

       
   * Note that, rotate one object 180º to the opposite side, only requires to change positive by negative in the 2 axes that move and leave the rotating one as is.


   Ok, enough for 1's and 0's but and the others numbers?

   First let's keep with rotations in one axe, to show that it is still valid that the value of the axe wich is rotating don't change, only the others two axes change their values.
   When the rotation it's not a multiple of 90º we began to see decimal numbers:
   
   0.707 -0.707 0   0.707 0.707,0    0 0 1 --> this a 45º rotation along the Z axe



   and when the three axes rotate in not multiple of 90º we got that known festival of numbers (here simplified):

   0.5 -0.709 -0.498    -0.866 -0.41   -0.287 0 0.547 -0.819 --> arbitrary rotation in the 3 axes



   A couple of things more:

   If some of the axes is 0 0 0 the object is flattened in that axe

   If you substitute the unit by the same number in the three axes the object becomes scaled,
 
   so   0.5 0 0   0 0.5 0   0 0 0.5    is 1/2 scale   and     10 0 0   0 10 0  0 0 10   makes the object 10 times bigger

   if the numbers are different in every axe , the object becomes scaled differently in each one of them.
   if you got 2 values for the same axe that axe becomes stretched or squewed :  100 110 001 (two values for the x coordinate)


   In next part we'll learn how to see Matrix3 values in Max, and how to change them with the MaxScript tool, but for now I need some rest to all this 1 and 0's...
   My apologies to Crazyflak and Raptor for make them wait. I feel that this issue was of general interest so I wanted to finish first. I've seen the post of Cirx about his POV mod and some things    seemed to me as been misunderstood or lacking of some better explanation, (seen the date of the post I already have the feeling of getting late) also as all of this applies to many others things related to hooks, I wanted to make a "fast" move to fix it, but this has taken much more than I expected... ???
   Anyway I hope that this be of any help. if you have some corrections or doubts or whatever just feel free to comment  ;)

PD:I repeated some pics intentionally to avoid scrolling and sorry for the big size of pictures, those lines tend to dissapear at lower resolutions... :P

Maybe is a silly thing, but I forgot to added this:

5º  --> 0.062      50º --> 0.766
10º --> 0.123      55º --> 0.819
15º --> 0.259      60º --> 0.866
20º -->   0.342      65º --> 0.906
25º -->   0.495      70º --> 0.94
30º -->   0.5      75º --> 0.966
35º -->   0.574      80º --> 0.985
40º -->   0.643      85º --> 0.996
45º --> 0.707

Helps to give you and idea looking at the numbers in the .msh file of how much is rotated an axe in degrees so you can figure out how is orientated the hook.
here an example:

0 0.5 -0.866025 1 0 0 0 -0.866025 -0.5 0.00712 -0.3945 -0.60937

Looking at these numbers you can say that the X local axe is rotated 90º to the left so now points to your front and 60º down, the Y axe is rotated 90º to your right so now points straight to your right and the Z axe is pointing to your back rotated 30º down (note 60º and 30º sum 90º)

In every case you'll find two numbers repeated in diferent axes and the sum of the angles they represent is ALWAYS 90º (remember they're perpendicular to each other)

Also forget to mention that sometimes you'll find numbers like 5.2727E-07 (or 5.2727e-07) don't know the words in english (scientifc notation?) This represent a decimal number with as many zeros after the point as the last number after the E says, just think of it like a very close to zero number and don't complicate.
hope it helps!



 
Logged

SAS~Malone

  • flying as #46 with the FAC
  • Editor
  • member
  • Offline Offline
  • Posts: 14439
  • proud member of that 'other' site
Re: understanding orientation of hooks
« Reply #1 on: July 25, 2010, 10:18:06 AM »

this is fantastic stuff, champi!
it'll definitely help me with some of the issues i've been trying to figure out.
thanks very much for this explanation!  ;D 8)
Logged
.....taking fun seriously since 1968.....  8)

SAS~CirX

  • Editor
  • member
  • Offline Offline
  • Posts: 4744
  • No Zips, Only Buttons
Re: understanding orientation of hooks
« Reply #2 on: July 25, 2010, 10:51:56 AM »

Awesome tutorial Champi! Many many thanks! :)
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 16370
  • Ask me if I care.
    • Friendly Fire isn't.
Re: understanding orientation of hooks
« Reply #3 on: July 25, 2010, 12:13:31 PM »

Best explanation regarding this topic I've ever seen.

Thanks a bomb!

Best regards - Mike
Logged
Learn. Challenge. Improve. In loving memory of the times when I cared...

SAS~GJE52

  • SAS Team
  • member
  • Offline Offline
  • Posts: 4403
Re: understanding orientation of hooks
« Reply #4 on: August 04, 2010, 12:28:24 PM »

Brilliant tutorial champi - many thanks for posting this, it is a real help to me, I now understand what the "code" is  ;),

By the way in answer to your question,

Quote
Also forget to mention that sometimes you'll find numbers like 5.2727E-07 (or 5.2727e-07) don't know the words in english (scientifc notation?) This represent a decimal number with as many zeros after the point as the last number after the E says, just think of it like a very close to zero number and don't complicate.
hope it helps!

Natural (Naperian) logarithms      The base is e.
e is an irrational number where e = 2.71828...  The symbol "ln" refers to natural logarithms.
    loge x = ln x    ln x is the exponent to which e must be raised to get x.
So

e0 = 1
e1 = 2.71828
e2 = 7.39

Conversely

e-01 = 0.3678
e-07 = 0.000911881

5.2727e-07 =0.0048

The important thing here is that 5.2727e-07 is so small as to be effectively zero for our purposes when compared with the other numbers in the string, so you may replace these entries with zero, which greatly simplifies the string .


Glynn
Logged
"The darkest places in Hell are reserved for those who maintain their neutrality in times of moral crisis"  The Divine Comedy. Dante Alighieri 1265-1321

just champi

  • Modder
  • member
  • Offline Offline
  • Posts: 607
Re: understanding orientation of hooks
« Reply #5 on: August 04, 2010, 12:45:16 PM »

Many thanks for the explanation GJE52,  :)
Now seems much clearer, and also that I'm really "null" in maths...  :-[
I was lost in high school when they talked about "logaritmos neperianos" (in spanish)  :(
I wish a was being paying atention to that maths teacher in my school days instead of thinking on butterflies... ::)

ehmm.. yeah, they are lovely, isn't it? :-\
Logged

SAS~GJE52

  • SAS Team
  • member
  • Offline Offline
  • Posts: 4403
Re: understanding orientation of hooks
« Reply #6 on: August 04, 2010, 01:32:04 PM »

Looking back, I wish I had spent more time thinking of butterflies,  :( ,  but thanks again for the tutorial, it is a real help.

G
Logged
"The darkest places in Hell are reserved for those who maintain their neutrality in times of moral crisis"  The Divine Comedy. Dante Alighieri 1265-1321

LuseKofte

  • member
  • Offline Offline
  • Posts: 6740
Re: understanding orientation of hooks
« Reply #7 on: August 04, 2010, 03:36:39 PM »

This I might be able to understand wait a minute I think I need to read it again.
But really this is some great explanation you got here, its saved  Thank you   ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.045 seconds with 27 queries.