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 / 11641
Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Wed, 23 Jun 2004 15:39:05 GMT
Viewed: 
3714 times
  
In lugnet.cad, Don Heyse wrote:
If anyone wants to update MIRROR.INI for all 2500 parts, that'd be
fantastic.

In mirror.ini, you noted:
; NOTE: I started using the Flags to keep track of which parts I checked.
;          0 = not checked.
;          1 = substitute part
;          2 = mirror across XY plane instead of default of ZY plane
;          3 = mirror and rotate a bit.
;          4 = mirror across XZ plane.  (common for studless technic liftarms)

I'm adding another flag value:
;          5 = checked (ie, reflect across YZ plane)

Some of the flag values should be combinable.  2 and 4 are mutually exclusive,
but 2 and 3 can go together.  So maybe this would be a more rational mapping:
;          0 = not checked.
;          1 = mirror across YZ plane (standard)
;          2 = mirror across XY plane
;          3 = mirror across XZ plane (common for studless technic liftarms)
;          4 = substitute part
;          8 = rotate a bit
Then the 4 and 8 values can be added to the mirror bits.

HTH,
Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Wed, 23 Jun 2004 15:44:47 GMT
Viewed: 
3806 times
  
In lugnet.cad, Steve Bliss wrote:
I'm adding another flag value:
;          5 = checked (ie, reflect across YZ plane)

and another two:
;          6 = asymmetric
;          7 = asymmetric, but in a non-significant way

Part 108 (a shock absorber spring) is getting a 7.

Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 14:32:37 GMT
Viewed: 
4053 times
  
What about a flag for default behavior?  I've been coding to ignore ones with default rotations, but there are plenty of parts (especially slopes) that need a (-1 0 0 0 1 0 0 0 1) rotation applied when reflected front-to-back and it would be nice to have a flag to distinguish those needing default behavior from those where the true correction matrix is (-1 0 0 0 1 0 0 0 1).

Carl


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 14:35:56 GMT
Viewed: 
4152 times
  
In lugnet.cad, Carl Nelson wrote:
What about a flag for default behavior?  I've been coding to ignore ones with default rotations, but there are plenty of parts (especially slopes) that need a (-1 0 0 0 1 0 0 0 1) rotation applied when reflected front-to-back and it would be nice to have a flag to distinguish those needing default behavior from those where the true correction matrix is (-1 0 0 0 1 0 0 0 1).

Never mind.  5 would be the correct value for this, right?


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 15:09:39 GMT
Viewed: 
4134 times
  
In lugnet.cad, Carl Nelson wrote:
What about a flag for default behavior?  I've been coding to ignore
ones with default rotations,

Why?  I have a slow PC, and running the mirwiz.exe program is
nearly instantaneous.  It's a lookup and 2 matrix multiplies per
part.  If the exception matrix lookup fails, use the default matrix.
It would take extra, unneeded code to ignore things.  Resist the
urge...

but there are plenty of parts (especially slopes) that need a
(-1 0 0 0 1 0 0 0 1) rotation

Stop saying rotation.  It makes me think you're not doing it right.
That's a mirror matrix.

applied when reflected front-to-back
and it would be nice to have a flag to distinguish those needing
default behavior from those where the true correction matrix is
(-1 0 0 0 1 0 0 0 1).

If you *always* do the same matrix math there's no need to
distinguish.  If you're not, then you're making extra busy work
for yourself and possibly introducing bugs.  Here's the pseudo code.

  for (*ALL* parts in the subfile)
  {
    float m[4][4];  // Tempory working matrix.
    float md[4][4] = { // Default = left-right mirror
      {-1.0,0.0,0.0,0.0},
      {0.0,1.0,0.0,0.0},
      {0.0,0.0,1.0,0.0},
      {0.0,0.0,0.0,1.0}
    };
    float *me = md; // Init exception mirror to left-right (the default).
    float *mp = md; // Init global subfile mirror to left-right.

    for( i=0; i< numExceptions; i++ )
    {
       if (exception[i] matches this part)
       {
  // Use the matrix from the exception list (instead of md).
  me = exception[i].matrix
  // Also use the substitute partname
  strcpy(datname, exception[i].datname);
  break;
}
    }
    M4M4Mul(m,LinePtr->v,me); // Run the initial mirror on the part
    M4M4Mul(LinePtr->v,mp,m); // Apply global subfile mirror to part

    // NOTE: You can set mp to mirror across whatever plane you want.
    //       The example here mirrors the subfile across the YZ plane.
  }

It's simple and it's all done with mirrors, except for a few weird
parts which might contain a rotation and/or translation component
mixed in with the mirroring in the me matrix.

So far I've only found a few door parts that need a translation
component.  See http://ldglite.sf.net/mirror.ini for details on
the doors.

Enjoy,

Don


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 15:18:49 GMT
Viewed: 
4265 times
  
In lugnet.cad, Carl Nelson wrote:
In lugnet.cad, Carl Nelson wrote:
What about a flag for default behavior?  I've been coding to ignore
ones with default rotations, but there are plenty of parts
(especially slopes) that need a (-1 0 0 0 1 0 0 0 1) rotation
applied when reflected front-to-back and it would be nice to have a
flag to distinguish those needing default behavior from those where
the true correction matrix is (-1 0 0 0 1 0 0 0 1).

Never mind.  5 would be the correct value for this, right?

I don't think so.  5 is for keeping track of which parts we've looked
at, not which ones to ignore when your run your mirror program.
Eventually I think we'll remove all the ones marked with a 5 from the
MIRROR.INI file.  (And that includes the left-right symmetric slopes
because they use the default matrix).

Don


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 17:53:31 GMT
Viewed: 
4218 times
  
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Carl Nelson wrote:
What about a flag for default behavior?  I've been coding to ignore
ones with default rotations,

Why?  I have a slow PC, and running the mirwiz.exe program is
nearly instantaneous.  It's a lookup and 2 matrix multiplies per
part.  If the exception matrix lookup fails, use the default matrix.
It would take extra, unneeded code to ignore things.  Resist the
urge...

Why process something as an exception when the default behavior is needed?  It's
all in what one sees as extra, unneeded code. ;-)

Though I just did some timing and I don't see any performance differences
between ignoring them and not.

but there are plenty of parts (especially slopes) that need a
(-1 0 0 0 1 0 0 0 1) rotation

Stop saying rotation.  It makes me think you're not doing it right.
That's a mirror matrix.

Exception matrix would probably be the best term, since it *always* mirrors and
*may* rotate.

If you *always* do the same matrix math there's no need to
distinguish.  If you're not, then you're making extra busy work
for yourself and possibly introducing bugs.  Here's the pseudo code.

  for (*ALL* parts in the subfile)
  {
    float m[4][4];  // Tempory working matrix.
    float md[4][4] = { // Default = left-right mirror
      {-1.0,0.0,0.0,0.0},
      {0.0,1.0,0.0,0.0},
      {0.0,0.0,1.0,0.0},
      {0.0,0.0,0.0,1.0}
    };
    float *me = md; // Init exception mirror to left-right (the default).
    float *mp = md; // Init global subfile mirror to left-right.

    for( i=0; i< numExceptions; i++ )
    {
       if (exception[i] matches this part)
       {
  // Use the matrix from the exception list (instead of md).
  me = exception[i].matrix
  // Also use the substitute partname
  strcpy(datname, exception[i].datname);
  break;
}
    }
    M4M4Mul(m,LinePtr->v,me); // Run the initial mirror on the part
    M4M4Mul(LinePtr->v,mp,m); // Apply global subfile mirror to part

    // NOTE: You can set mp to mirror across whatever plane you want.
    //       The example here mirrors the subfile across the YZ plane.
  }

It's simple and it's all done with mirrors, except for a few weird
parts which might contain a rotation and/or translation component
mixed in with the mirroring in the me matrix.

My reservation about doing it this way is that it is exclusively tied to a reflection matrix of (-1 0 0 0 1 0 0 0 1)--please see my response to your 2nd message.

So far I've only found a few door parts that need a translation
component.  See http://ldglite.sf.net/mirror.ini for details on
the doors.

Same here.  BTW, do you want me to send you the parts that I've changed
mirror.ini for already?  I've also confirmed some as correct by rotating
different models.

Carl


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 17:54:55 GMT
Viewed: 
4355 times
  
In lugnet.cad, Don Heyse wrote:
I don't think so.  5 is for keeping track of which parts we've looked
at, not which ones to ignore when your run your mirror program.
Eventually I think we'll remove all the ones marked with a 5 from the
MIRROR.INI file.  (And that includes the left-right symmetric slopes
because they use the default matrix).

IMO there *is* value to knowing that the proper exception matrix is indeed an
exception rather than coincidentally the same as the default matrix.  If the 5
is not the place for this, there should be a new flag for it.

It's especially important if all the 5s are removed.  If so, the left-right symmetric slopes with an exception matrix of -1 0 0 0 1 0 0 0 1 will only function properly for left-right reflections because that's the only case where their exception matrix would equal the "default" matrix.  ("Default" in quotes because it should probably be the mirror-plane matrix or some other term that describes what it is.)

Of course, this supports your methodology of treating every part listed in
mirror.ini as an exception regardless of whether it happens to use the
reflection matrix. ;-)  But it would still fail if those true exceptions were
removed.

Thanks,
Carl


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 18:57:26 GMT
Viewed: 
4377 times
  
In lugnet.cad, Carl Nelson wrote:
In lugnet.cad, Don Heyse wrote:
I don't think so.  5 is for keeping track of which parts we've looked
at, not which ones to ignore when your run your mirror program.
Eventually I think we'll remove all the ones marked with a 5 from the
MIRROR.INI file.  (And that includes the left-right symmetric slopes
because they use the default matrix).

IMO there *is* value to knowing that the proper exception matrix is
indeed an exception rather than coincidentally the same as the
default matrix.  If the 5 is not the place for this, there should be
a new flag for it.

Sure, but you still haven't convinced me there's any difference
between a 2x2 brick and a 2x2 slope brick.  I must be getting senile
in my old age, because I just don't get it.

Anyhow, use 55 if it makes you happy.  We'll figure out what to do
with it later when my brain starts working.  Steve's already switched
over to some other weird notation for the flag field.  Maybe you
should send him a note and you two can duke it out.  And perhaps you
can send my your code and it'll all become clear to me.  I don't know.

It's especially important if all the 5s are removed.  If so, the
left-right symmetric slopes with an exception matrix of -1 0 0 0 1 0
0 0 1 will only function properly for left-right reflections because
that's the only case where their exception matrix would equal the
"default" matrix.  ("Default" in quotes because it should probably be
the mirror-plane matrix or some other term that describes what it
is.)

What do you mean by function properly?  As far as I know, I can
change the global subfile mirror matrix (mp in my code sample) to a
mirror across *any* arbitrary plane and it should still work.  I've
compiled mirwiz.c with a front-back mp and it still works.

    float mm[4][4] = { // Front-back mirror
      {1.0,0.0,0.0,0.0},
      {0.0,1.0,0.0,0.0},
      {0.0,0.0,-1.0,0.0},
      {0.0,0.0,0.0,1.0}
    };
    //float *mp = md; // Init global mirror to left-right.
    float *mp = mm; // Init global mirror to front-back.

What else do you need to function properly?  The whole point of the
exception matrix is to prepare each part so that the *real* mirror
(the global subfile mirror operation) is in fact an UNmirror operation
because all the parts are already mirrored.  You just can't tell
they're already mirrored unless you look at the backwards logos in
MLCAD or POV output.

Go ahead and try it.  Just apply the exception matrices to a
subfile.  It should come out looking identical.  But if you look
really close at the logos in MLCAD you'll see they're backwards,
ready to be fixed by *any* mirror operation.  (Don't use ldview
or ldglite though because they fix the logos on the fly if they
detect a negative determinant.)

Am I mistaken about this somehow?  Does it somehow produce parts
that aren't mirrored, but also aren't real?  Show me the mangled
LDR file.

Of course, this supports your methodology of treating every part
listed in mirror.ini as an exception regardless of whether it happens
to use the reflection matrix. ;-) But it would still fail if those
true exceptions were removed.

I'm still not seeing that.  Steve?  Help me out here.  What am I
missing?

BTW, do you want me to send you the parts that I've changed
mirror.ini for already?  I've also confirmed some as correct by
rotating different models.

You're not a SourceForge member, are you?  This merging would be so
much simpler if we could just let CVS merge the changes for us.
Since you're probably not, maybe you could send the changes to Steve.
(and send me a copy too)  He's taking a rational approach.  Doing
the ones and then the two's, whereas I just fool around and look
at wings or doors or whatever strikes my fancy.

Have fun,

Don


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 21:06:32 GMT
Viewed: 
4270 times
  
In lugnet.cad, Carl Nelson wrote:
Why process something as an exception when the default behavior is needed?
It's all in what one sees as extra, unneeded code. ;-)

Well, yeah.  But it's simpler to process it all -- the only exceptional
processing you need is "look for the part in mirror.ini.  If not found, use the
default settings".

With your method, you have to also add "if the matrix looks like MD, then
process with method_a; otherwise, use method_b".

HOWEVER, you should process all parts through the mirroring operation -
otherwise, you can't handle parts at arbitrary orientations.  And if you apply
just the reflection matrix (MP), you'll get reversed stud-logos in your
renderings.

Exception matrix would probably be the best term, since it *always* mirrors > and *may* rotate.

Or transformation matrix, or pre-reflection matrix.

Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 21:11:29 GMT
Viewed: 
4362 times
  
Oops, I missed replying to one point.

In lugnet.cad, Carl Nelson wrote:
My reservation about doing it this way is that it is exclusively tied to a
reflection matrix of (-1 0 0 0 1 0 0 0 1)--please see my response to your
2nd message.

If you mean (-1 0 0 0 1 0 0 0 1) as the 'default' matrix, my response is: that default matrix works for *any* reflection across any arbitrary plane.

If you mean (-1 0 0 0 1 0 0 0 1) as the reflection matrix, my response is: Don's algorithm works for *any* reflection across any arbitrary plane.

Steve


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 21:23:03 GMT
Viewed: 
4468 times
  
In lugnet.cad, Steve Bliss wrote:
Oops, I missed replying to one point.

In lugnet.cad, Carl Nelson wrote:
My reservation about doing it this way is that it is exclusively tied to a
reflection matrix of (-1 0 0 0 1 0 0 0 1)--please see my response to your
2nd message.

If you mean (-1 0 0 0 1 0 0 0 1) as the 'default' matrix, my response is:
that default matrix works for *any* reflection across any arbitrary plane.

If you mean (-1 0 0 0 1 0 0 0 1) as the reflection matrix, my response is:
Don's algorithm works for *any* reflection across any arbitrary plane.

Uh, I thought we were refering to it as "Steve's algorithm".  Are you
having 2nd thoughts?  ;^)

Enjoy,

Don

PS.  Why am I constantly seeing really long lines in the browser for this
thread.  It makes things really hard to read when I have to scroll 2
miles to the right.


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 21:49:15 GMT
Viewed: 
4506 times
  
In lugnet.cad, Don Heyse wrote:
Uh, I thought we were refering to it as "Steve's algorithm".  Are you
having 2nd thoughts?  ;^)

Sorry, I should have said "Don's pseudo-code". ;)

PS.  Why am I constantly seeing really long lines in the browser for this
thread.  It makes things really hard to read when I have to scroll 2
miles to the right.

I don't know - I'm replying via the web interface, posting with plain text.


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Fri, 25 Jun 2004 02:43:13 GMT
Viewed: 
4533 times
  
In lugnet.cad, Steve Bliss wrote:
Oops, I missed replying to one point.

In lugnet.cad, Carl Nelson wrote:
My reservation about doing it this way is that it is exclusively tied to a
reflection matrix of (-1 0 0 0 1 0 0 0 1)--please see my response to your
2nd message.

If you mean (-1 0 0 0 1 0 0 0 1) as the 'default' matrix, my response is: that default matrix works for *any* reflection across any arbitrary plane.

If you mean (-1 0 0 0 1 0 0 0 1) as the reflection matrix, my response is: Don's algorithm works for *any* reflection across any arbitrary plane.

Alright, I give up then.  I've accomplished my original goal of mirroring a
model, and I'm just confusing and frustrating myself and wasting your and Don's
time with stupid questions.

I've put the newest executable & source code at:

http://www.carlnelson.com/page.asp?SID=1&Page=43

Thanks,
Carl


Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Fri, 2 Jul 2004 21:08:06 GMT
Viewed: 
4845 times
  
In lugnet.cad, Carl Nelson wrote:
I've put the newest executable & source code at:

http://www.carlnelson.com/page.asp?SID=1&Page=43

Before I forget, Steve finished examining all the parts, so
I've put the complete mirror.ini file here for now.

  http://ldglite.sourceforge.net/mirwiz.zip

Enjoy,

Don


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