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 / 11598
Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Fri, 18 Jun 2004 17:52:59 GMT
Viewed: 
3172 times
  
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Don Heyse wrote:
Talking to myself...

Here's what I'm talking about.  Completely ripped off from the
MLcad.ini file.

  http://ldglite.sf.net/mirror.ini

That one contains an entry every part in my parts.lst file.  It
needs to have the changes made for the exceptions, but here's
how it starts.

;
; Mirror.ini
;
; ============================================================================
; This file is read by subfile mirror programs
; ============================================================================
; Lines beginning with ; are comments ...
; Empty lines are ignored

; This file contains information used to mirror a subfile across the Z axis.
; Many parts are symmetric across the Z axis and can be mirrored by simply
; negating the Z coordinate of the part in the subfile.
; Other parts need additional rotation, translation, and possibly substitution.
; This file tells what to do for those exceptional parts.
;
; Each line has the following format:
; PARTNAME MIRRORPART <Flags> <Matrix> <Offset>
; <PARTNAME> The name of the part file
; <MIRRORPART> The file name of the substutute part.
;              (It's the same as PARTNAME if no substitution is required.
; <Flags> always 0 reserved for future use
; <Matrix> a rotation matrix a11 a12 a13 ... a33 for optimal appearance at
;          0 degree rotation angle
; <Offset> The offset of the part to be in place
;

[MIRRORSETTINGS]
2546.DAT            2546.DAT            0  1 0 0 0 1 0 0 0 1  0 0 0
2546P01.DAT         2546P01.DAT         0  1 0 0 0 1 0 0 0 1  0 0 0
6029A.DAT           6029A.DAT           0  1 0 0 0 1 0 0 0 1  0 0 0


Special: 
[DAT] (requires LDraw-compatible viewer)
Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Fri, 18 Jun 2004 19:59:25 GMT
Viewed: 
3188 times
  
In lugnet.cad, Don Heyse wrote:
Here's what I'm talking about.  Completely ripped off from the
MLcad.ini file.

  http://ldglite.sf.net/mirror.ini

That one contains an entry every part in my parts.lst file.  It
needs to have the changes made for the exceptions, but here's
how it starts. • [...]
2546.DAT            2546.DAT            0  1 0 0 0 1 0 0 0 1  0 0 0
2546P01.DAT         2546P01.DAT         0  1 0 0 0 1 0 0 0 1  0 0 0
6029A.DAT           6029A.DAT           0  1 0 0 0 1 0 0 0 1  0 0 0

I think I've got a more general solution, but first a quick thought: You could
make mirror.ini more human-readable if the 'normal' parts were just flagged.
Something like:

2546.DAT      default
41770.DAT     exception  41769.DAT     0  1 0 0 0 1 0 0 0 1  0 0 0

On to the weird stuff, apologies if the following covers ground already
discussed.

It seems like mirror.ini will work for the basic case, where parts are not
rotated (or only rotated by 90 degree increments around the Y-axis).  But what
about exception parts at arbitrary orientations?  I'm not very good at thinking
in terms of matrix math, so I worked through a concrete example.

I used the 2x4 wings, 41770 and 41769.  I mirrored along the X axis (my
mistake), but I'll get back to Z axis mirroring in a bit.  The 41770's
X-axis-style entry in MIRROR.INI would be like:
41770.DAT           41769.DAT           0  -1 0 0 0 1 0 0 0 1 0 0 0

So I put a 41770 in a model file and postioned it like this:
1 4 130 -70 -130 .39 -.64 -.66 .6 .72 -.34 .7 -.27 .66 41770.dat

Then I tried to mirror it cleanly.  That is, I wanted to end up with 41769 in
the position/orientation corresponding to my 41770, which means that its final
transformation matrix would be 'non-mirroring'.  What I ended up with is this
LDLite language:
0 TRANSFORM 0 0 0 -1 0 0 0 1 0 0 0 1
  0 TRANSFORM 130 -70 -130 .39 -.64 -.66 .6 .72 -.34 .7 -.27 .66
    1 3 0 0 0 -1 0 0 0 1 0 0 0 1 41769.dat
  0 TRANSFORM END
0 TRANSFORM END

Translated back to simple LDraw, this code turns into:
1 3 -130 -70 -130 .39 .64 .66 -.6 .72 -.34 -.7 -.27 .66 41769.dat

Getting back to mirroring along the Z axis:  I figured out that the correct
equivalent Z axis mirror operation looks like this:
0 TRANSFORM 0 0 0 1 0 0 0 1 0 0 0 -1
  0 TRANSFORM 130 -70 -130 .39 -.64 -.66 .6 .72 -.34 .7 -.27 .66
    1 3 0 0 0 -1 0 0 0 1 0 0 0 1 41769.dat
  0 TRANSFORM END
0 TRANSFORM END

What's interesting is the pre-mirrored part (41769) is inlined with the same transformation as before (-1 0 0 0 1 0 0 0 1).  I expected that I'd have to rotate 41769 180 degrees, and then reposition it, to make things work.

After thinking about it, I think what happened is this:  instead of trying to map 41770 to 41769 in some way that is equivalent to a mirroring operation, I actually replaced the original part with an already-mirrored equivalent statement.  That is, I replaced the '41770.dat' in the first statement with '1 16 0 0 0 -1 0 0 0 1 0 0 0 1 41769.dat', like an inlined subfile.  Since this part was pre-mirrored, applying the mirroring transformation actually 'un-mirrored' the 41769.

So, to make a long story short - I don't think MIRROR.INI should specify how to
transform part A into part B without a mirror operation.  It should specify the
opposite: how to mirror part B into part A with a mirroring operation, so
mirroring-programs can take the transformation being used on part A in the model
file and wrap it around the mirrored part B.

The main practical effect on MIRROR.INI would be that normal parts would have a mirroring transform (1 0 0 0 1 0 0 0 -1) instead of the standard transform.


Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Fri, 18 Jun 2004 23:31:55 GMT
Viewed: 
3325 times
  
In lugnet.cad, Steve Bliss wrote:
In lugnet.cad, Don Heyse wrote:
Here's what I'm talking about.  Completely ripped off from the
MLcad.ini file.

  http://ldglite.sf.net/mirror.ini

That one contains an entry every part in my parts.lst file.  It
needs to have the changes made for the exceptions, but here's
how it starts. [...]
2546.DAT            2546.DAT            0  1 0 0 0 1 0 0 0 1  0 0 0
2546P01.DAT         2546P01.DAT         0  1 0 0 0 1 0 0 0 1  0 0 0
6029A.DAT           6029A.DAT           0  1 0 0 0 1 0 0 0 1  0 0 0

I think I've got a more general solution, but first a quick thought:
You could make mirror.ini more human-readable if the 'normal' parts
were just flagged.  Something like:

2546.DAT      default
41770.DAT     exception  41769.DAT     0  1 0 0 0 1 0 0 0 1  0 0 0

Actually I was thinking of deleting them from the file to make it
smaller.  The only problem is remembering which ones were deleted and
which ones are new at update time.  I'm not sure how to automate
additions either way.  Probably have to use the sorted properties of
parts.lst

So, to make a long story short - I don't think MIRROR.INI should
specify how to transform part A into part B without a mirror operation.
It should specify the opposite: how to mirror part B into part A with
a mirroring operation, so mirroring-programs can take the
transformation being used on part A in the model file and wrap it
around the mirrored part B.

The main practical effect on MIRROR.INI would be that normal parts
would have a mirroring transform (1 0 0 0 1 0 0 0 -1) instead of the
standard transform.

I think that makes sense.  Apply the mirror transform and/or substitution
from MIRROR.INI individually to all parts in the subfile, then apply a
global mirror (across whatever axis you want) to the whole subfile.

It sounds so simple.  Could it be?

Don


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Mon, 21 Jun 2004 13:35:53 GMT
Viewed: 
3372 times
  
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Steve Bliss wrote:
You could make mirror.ini more human-readable if the 'normal' parts
were just flagged.  Something like:

2546.DAT      default
41770.DAT     exception  41769.DAT     0  1 0 0 0 1 0 0 0 1  0 0 0

Actually I was thinking of deleting them from the file to make it
smaller.  The only problem is remembering which ones were deleted and
which ones are new at update time.  I'm not sure how to automate
additions either way.  Probably have to use the sorted properties of
parts.lst

Keep a full.mirror.ini, with all the default entries.  A simple grep drop the
extra lines, giving us mirror.ini.

I think that makes sense.  Apply the mirror transform and/or substitution
from MIRROR.INI individually to all parts in the subfile, then apply a
global mirror (across whatever axis you want) to the whole subfile.

It sounds so simple.  Could it be?

Well, it depends entirely on whether or not applying two mirroring
transformations always gives an un-mirrored result.  If that's true, then we're
good.

Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Mon, 21 Jun 2004 13:55:35 GMT
Viewed: 
3462 times
  
In lugnet.cad, Steve Bliss wrote:
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Steve Bliss wrote:
You could make mirror.ini more human-readable if the 'normal' parts
were just flagged.  Something like:

2546.DAT      default
41770.DAT     exception  41769.DAT     0  1 0 0 0 1 0 0 0 1  0 0 0

Actually I was thinking of deleting them from the file to make it
smaller.  The only problem is remembering which ones were deleted and
which ones are new at update time.  I'm not sure how to automate
additions either way.  Probably have to use the sorted properties of
parts.lst

Keep a full.mirror.ini, with all the default entries.  A simple grep
drop the extra lines, giving us mirror.ini.

Or generate a parts.lst (and stash it somewhere) before adding parts,
then diff it with the new parts.lst.  I'm not sure how grep fits into
your plan though...

I think that makes sense.  Apply the mirror transform and/or substitution
from MIRROR.INI individually to all parts in the subfile, then apply a
global mirror (across whatever axis you want) to the whole subfile.

It sounds so simple.  Could it be?

Well, it depends entirely on whether or not applying two mirroring
transformations always gives an un-mirrored result.  If that's true,
then we're good.

My math intuition says it should be.  There are only two choices for
the sign of the determinant, and I think multiplying a negative matrix
by a negative matrix must result in a positive.  Two wrongs *do* make
a right.  Right?

Don


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Mon, 21 Jun 2004 15:00:09 GMT
Viewed: 
3285 times
  
In lugnet.cad, Steve Bliss wrote:
The main practical effect on MIRROR.INI would be that normal parts
would have a mirroring transform (1 0 0 0 1 0 0 0 -1) instead of the
standard transform.

Err, Shouldn't that be (-1 0 0 0 1 0 0 0 1)?  You have to negate the
X coordinate to mirror across the Z axis.

Don


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Mon, 21 Jun 2004 16:12:11 GMT
Viewed: 
3350 times
  
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Steve Bliss wrote:
The main practical effect on MIRROR.INI would be that normal parts
would have a mirroring transform (1 0 0 0 1 0 0 0 -1) instead of the
standard transform.

Err, Shouldn't that be (-1 0 0 0 1 0 0 0 1)?  You have to negate the
X coordinate to mirror across the Z axis.

Sorry, I misunderstood the terminology.  I figured you could either mirror
across a plane, or along a line.  You can't mirror across a line - it's 1D.  So
I assumed when people were writing about mirroring 'across the Z axis', they
meant to use the XY plane as the mirror.

So, yeah - for right/left mirroring, you'd negate the X coordinate.

Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Mon, 21 Jun 2004 16:32:44 GMT
Viewed: 
3377 times
  
In lugnet.cad, Steve Bliss wrote:
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Steve Bliss wrote:
The main practical effect on MIRROR.INI would be that normal parts
would have a mirroring transform (1 0 0 0 1 0 0 0 -1) instead of the
standard transform.

Err, Shouldn't that be (-1 0 0 0 1 0 0 0 1)?  You have to negate the
X coordinate to mirror across the Z axis.

Sorry, I misunderstood the terminology.  I figured you could either mirror
across a plane, or along a line.  You can't mirror across a line - it's 1D.
So I assumed when people were writing about mirroring 'across the Z axis',
they meant to use the XY plane as the mirror.

Heh, I was thinking 2-dimensionally.  It's easier for my tired old
brain.  All my sketches were happening on the XZ plane so mirroring
across the Z axis made total sense to me.  Oh well.

So, yeah - for right/left mirroring, you'd negate the X coordinate.

Ok, now I have to follow through and actually make a reference program
which uses the MIRROR.INI file, or this will all be for nothing.

Don


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