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 5906 times)

0 Members and 1 Guest are viewing this topic.

just champi

  • Modder
  • member
  • Offline Offline
  • Posts: 608
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: 14562
  • 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

  • R.I.P.
  • SAS Honourable Member
  • member
  • Offline Offline
  • Posts: 5254
  • 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: 23878
  • Taking a timeout
    • STFU
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
Don't split your mentality without thinking twice.

SAS~GJE52

  • Editor
  • member
  • Offline Offline
  • Posts: 5175
  • Orchard Studios
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
Do not criticise a man until you have walked a mile in his shoes...  Then you can call him what you like, as you have his shoes ... and he is a mile away......

just champi

  • Modder
  • member
  • Offline Offline
  • Posts: 608
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

  • Editor
  • member
  • Offline Offline
  • Posts: 5175
  • Orchard Studios
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
Do not criticise a man until you have walked a mile in his shoes...  Then you can call him what you like, as you have his shoes ... and he is a mile away......

LuseKofte

  • member
  • Offline Offline
  • Posts: 6938
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

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6009
Re: understanding orientation of hooks
« Reply #8 on: August 27, 2022, 11:10:14 AM »

Just to add...

The transformation matrix, when used in a rotational capacity only (that is, when no rescaling is being applied), has a vector length of unity (1.0). The various numbers are then sines and cosines, and for any of the 3 groups of 3 values the square root of the sum of the squares will equal 1.0 (or very close to 1.0). For example, a 45 degree rotation might have a group present as 0.7071 -0.7071 0.0.  If you square 0.7071, then square -0.7071, then square 0.0, then add these values together, then take the square root of that sum, you will obtain 1.0.

The vertices of a model have a 'truncated' matrix for orienting surface normals, comprising 3 numbers; this is sufficient for a single vector. I do my 3D work with a spreadsheet, and so have to calculate the transform matrix for the surface normal for every vertex in the model (in addition to rotating a model component in a .him file.) This has the advantage of giving me full control, for I can orient the surface normal in any direction I want.

For example, an easy application of surface normal redirection involves the perspex and glass in canopies. There I simply reverse the sign of all 9 values of the matrix, which reverses the surface normal orientation. Now, instead of the texture being brightest when the Sun shines directly on the inside surface of the glazing, the texture is brightest when the Sun shines on that surface most directly from the outside. This simulates the way shmutz on glass is more efficient in scattering light in the forward direction than in backscatter.

Another application of surface normal control involves the lighting for the collimator reflection seen in my gunsights. The texture is either vertical or nearly so, facing the player. But the surface normals are not oriented perpendicular to that texture (pointing either toward or away from the player), but rather are made to point upward, in the direction above the pilot's head. This makes the texture appear brightest when the Sun is directly above the pilot's head, simulating the way the collimating lens will reflect sunlight most strongly when being illuminated from directly above. That reflection will be redirected by 90 degrees toward the pilot via the reflector plate. But more than that, the 4 surface normals at the corners of the reflection texture are not directed parallel to each other, but instead are splayed outward at an angle, all pointing away from the local zenith. This causes the texture to differentially vary in brightness across its face, simulating the reflection from a curved surface.

Another instance of surface normal control... The reflections off the P-39 panel gauge cover glass (in my cockpit mod) is set to be brightest when the Sun shines into the 'pit from forward and 45 degrees up. This means the surface normals are not pointed in the typical direction of back toward the pilot, but instead are pointing forward and 45 degrees up. This causes the reflections to be brightest when the interior rear of the cockpit is most directly illuminated, this brighter stuff being reflected by the flat gauge cover glass windows. The reflections will be dimmest when the Sun is behind and 45 degrees down, whereupon the 'pit aft interior will be in deepest shadow.

And there are other cases where 'non standard' surface normal orientations have been effected. I wonder if 3D software offers the facility to orient surface normals at will. This is a potent way to apply additional control of lighting for surfaces that are blocked from direct illumination over some range of solid angle, such as the lower interior of a cockpit. Indeed, I first tried this technique years ago for the ammo chutes feeding the Zero's cowl guns. Being tucked away well forward and under the dashboard, they would be most strongly lighted when the Sun is shining from behind and a bit up. And so I directed the surface normals that way; the effect is vastly superior to the usual treatment.
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)
Pages: [1]   Go Up
 

Page created in 0.037 seconds with 29 queries.