To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 5729
5728  |  5730
Subject: 
My VB DAT viewer and matrix handling
Newsgroups: 
lugnet.cad
Date: 
Tue, 10 Apr 2001 17:09:06 GMT
Viewed: 
460 times
  
I'm having some trouble working out the matrix handling for parts in a DAT
file given the parent DAT matrix. What I'm doing is the following:

let's say in a DAT I have:

1 0 X Y Z A B C D E F G H I parent.dat

and in parent.dat I have

1 0 x y z a b c d e f g h i child.dat

what I'm currently doing is combining the 2 matrices to apply to child.dat
in relation to the world coords in the form

x' = A*x + B*y + C*z + X
y' = D*x + E*y + F*z + Y
z' = G*x + H*y + I*z + Z

as per the LDraw FAQ, and then I'm combining the matrices as

a' = a*A
b' = b*D
c' = c*G
d' = d*B
e' = e*E
f' = f*H
g' = g*C
h' = h*F
i' = i*I

and then feeding this back to my line drawing routine to calculate the world
x, y, and z from the position x', y', z' of the child.dat part. However,
this is not working correctly, and I've also tried swapping the matrix calcs
to be

A' = A*a
B' = B*d
C' = C*g
D' = D*b
E' = E*e
F' = F*h
G' = G*c
H' = H*f
I' = I*i

and using these in my drawing routines, and I just get exactly the same
result.

If I don't use a matrix of 1 0 0 0 1 0 0 0 1 on parent.dat and instead get
my code to bypass matrix calcs for this everything is fine, all points in
all parts are placed correctly, but as soon as I applying this matrix it all
goes wrong - what appears to be happening is that the lines/triangles/quads
in parent.dat are placed correctly, but all parts have their Z reduced to
zero in all points when calculated before the rotation matrix is applied and
so they look wrong in all but one view (depending on the rotation - in
3626bp01.dat I get the eyes laying horizontal facing up - in the correct
x,y,z position, so my x' y' z' values appear to be correct, just not
rotated - and the 3626bs01 subpart looks fine from the front but all points
lie at Z=0).

Any ideas? Is there something glaringly obvious in my maths that I'm too
blind to see? Have I misinterpreted the LDraw FAQ?

Dan



Message has 3 Replies:
  Re: My VB DAT viewer and matrix handling
 
(...) Well, the Problem is that Combining Matrixes, is in fact a multiply betwwen the matrices, and what you are doing, it certainly isn't matrix multiply. Go get your algebra book or surf the Web and Find out how to do Matrix Multiplication. I'm (...) (23 years ago, 10-Apr-01, to lugnet.cad)
  Re: My VB DAT viewer and matrix handling
 
(...) shouldn't this be more in the line of a' = a*A + b*D + c*G b' = a*B + b*E + c*H c' = a*C + b*F + c*I d' = d*A + e *D + f*G ........ don't really know what your trying to do with the matrices. You should always tell what a variable is supposed (...) (23 years ago, 10-Apr-01, to lugnet.cad)
  Re: My VB DAT viewer and matrix handling
 
(...) [snip] (...) BTW, you can rewrite the whole problem as a matrix multiply: |a d g 1| |A D G 0| |b e h 1| x |B E H 0| |c f i 1| |C F I 0| |x y z 1| |X Y Z 1| Which doesn't seem very interesting, except that the left-hand matrix doesn't have to (...) (23 years ago, 11-Apr-01, to lugnet.cad)

7 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR