POV-Ray : Newsgroups : povray.binaries.images : Problem with 'seams' in merge. Server Time
13 Aug 2024 07:25:58 EDT (-0400)
  Problem with 'seams' in merge. (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Tor Olav Kristensen
Subject: Re: Problem with 'seams' in merge.
Date: 20 May 2003 18:27:09
Message: <Xns9382597D6647torolavkhotmailcom@204.213.191.226>
"Sun Tzu" <sun### [at] nospamhotmailcom> wrote in
news:3eca674d$1@news.povray.org: 

> Yes , yours was the image.  Thank you for posting it.  I enjoyed
> seeing it and trying to create something similar.

=)


> This was my first atempt at creating a macro so I'm sure there are
> many things that can be improved.  Please give me your suggestions so
> that I can learn.  :-)
...

0)
Not bad for a first try at writing a macro ;)


1)
Note that if you use #declare instead of #local inside the macro,
then the declared variable will exist and have a value also after
POV-Ray has finished parsing the macro.


2)
It can also be wise to store values, shapes, transformations etc.,
that are needed many times, in variables instead of calculating
them over and over again.


3)
When you store a primitive shape in a variable it is not necessary
to put it into an object {} statement.


4)
Transformations that are common to all shapes in a CSG operation
can be applied to the resulting CSG shape instead.

E.g.:

difference {
  object { torus_os ... rotate <0, 30, 0> }
  object { torus_is ... rotate <0, 30, 0> }
}

- is equal to:

difference {
  object { torus_os ... }
  object { torus_is ... }
  rotate <0, 30, 0>
}


5)
Many CSG operations can be simplified.

E.g. this expression:

difference {
  difference {
    object { insphere_os }
    object { insphere_is }
  }
  union {                                                
    object { cutcone ... }
    object { cutcone ... }
    object { cutcone ... }
    object { cutcone ... }
  }
}

- can be simplified to this:

difference {
  object { insphere_os }
  object { insphere_is }
  object { cutcone ... }
  object { cutcone ... }
  object { cutcone ... }
  object { cutcone ... }
}


6)
Note that intersection {} and difference {} are closely related.

I.e. this expression:

difference {
  object { Shape1 }
  object { Shape2 }
}

- can be rewritten as

intersection {
  object { Shape1 }
  object { Shape2 inverse }
}


And further:

intersection {
  difference {
    object { Shape1 }
    object { Shape2 }
  }
  object { Shape3 }
}

- as:

intersection {
  object { Shape1 }
  object { Shape2 inverse }
  object { Shape3 }
}


But IIRC there are some differences with regards to
automatic bounding. (But I don't remember exactly what.)


7)
It is my opinion that unless it makes things a lot simpler,
then you should avoid putting texturing and interior expressions
inside macros that genrates shapes.

E.g.: Your "material { Crystal }" statement inside your macro


8)
With POV-Ray versions 3.1 and later it should not ever
be necessary to enclose single variable names in brackets.

E.g.: (hole)


9)
Try to use more descriptive variable names.
(Yes, I know; it can sometimes be very hard to find good names.)


Below is my suggestion for a complete rewrite of your macro.


Tor Olav


#macro MakeThingy(Ra, Rb, Thickness, Rhole)

  #local Rdiff = Ra - Rb;
  #local Rmaj = Rb + Rhole;
  #local RminO = Rb;
  #local RminI = RminO - Thickness;
  #local ROO = Ra;
  #local ROI = ROO - Thickness;
  #local RII = Ra - 2*Rb;
  #local RIO = RII + Thickness;
  #local Hcone = Ra + 1;
  #local Rcone = Hcone*tan(asin(Rmaj/Rdiff));
  #local vUp = sqrt(Rdiff*Rdiff - Rmaj*Rmaj)*y;
  #local Angle = degrees(acos(-sqrt(1/3)));
  #local Nil = Ra*1e-6;

  #local OuterSphere_OuterSurface = sphere { 0*y, ROO }
  #local OuterSphere_InnerSurface = sphere { 0*y, ROI }
  #local InnerSphere_OuterSurface = sphere { 0*y, RIO }
  #local InnerSphere_InnerSurface = sphere { 0*y, RII }
  #local Torus_OuterSurface = torus { Rmaj, RminO translate vUp }
  #local Torus_InnerSurface = torus { Rmaj, RminI translate vUp }
  #local CutCone = cone { 0*y, 0, Hcone*y, Rcone }
  #local CutConeSmaller = cone { 0*y, 0, Hcone*y, Rcone - Nil }

  #local Trans0 = transform { }
  #local Trans1 = transform { rotate -Angle*z rotate  30*y }
  #local Trans2 = transform { rotate -Angle*z rotate 150*y }
  #local Trans3 = transform { rotate -Angle*z rotate 270*y }

  #local Spoke = 
    intersection {
      difference {
        object { Torus_OuterSurface } 
        object { Torus_InnerSurface }
      }
      object { CutCone }
    }

  #local CutCones =
    union {                                                
      object { CutConeSmaller transform { Trans0 } }
      object { CutConeSmaller transform { Trans1 } }
      object { CutConeSmaller transform { Trans2 } }
      object { CutConeSmaller transform { Trans3 } }
    }
  
  merge {
    difference {
      object { OuterSphere_OuterSurface }
      object { OuterSphere_InnerSurface }
      object { CutCones }
    }

    difference {
      object { InnerSphere_OuterSurface }
      object { InnerSphere_InnerSurface }
      object { CutCones }
    }

    object { Spoke transform { Trans0 } }
    object { Spoke transform { Trans1 } }
    object { Spoke transform { Trans2 } }
    object { Spoke transform { Trans3 } }
  }
 
#end // macro MakeThingy

 
object {
  MakeThingy(1000, 350, 10,100)
//  rotate 120*y
//  rotate degrees(acos(-sqrt(1/3)))*z
  material { Crystal }
}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Problem with 'seams' in merge.
Date: 20 May 2003 18:29:25
Message: <Xns93825FA76741torolavkhotmailcom@204.213.191.226>
10)
Please don't use html formatted text when posting to this news server.


Tor Olav


Post a reply to this message

From: Ken
Subject: Re: Problem with 'seams' in merge.
Date: 20 May 2003 18:34:11
Message: <3ECAAD86.BF1C2643@pacbell.net>
Tor Olav Kristensen wrote:

> #macro MakeThingy...

Nice name :)

-- 
Ken Tyler


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Problem with 'seams' in merge.
Date: 20 May 2003 18:42:23
Message: <Xns938282D43C50torolavkhotmailcom@204.213.191.226>
Ken <tyl### [at] pacbellnet> wrote in news:3ECAAD86.BF1C2643@pacbell.net:

> 
> 
> Tor Olav Kristensen wrote:
> 
>> #macro MakeThingy...
> 
> Nice name :)


Ehhhmm ... 

=)


Tor Olav


Post a reply to this message

From: Sun Tzu
Subject: Re: Problem with 'seams' in merge.
Date: 20 May 2003 19:03:50
Message: <3ecab456@news.povray.org>
Thank you for your many suggestions!  I tried the bigger cone as you
suggested and it worked perfectly.


Post a reply to this message


Attachments:
Download 'thingy2.jpg' (332 KB)

Preview of image 'thingy2.jpg'
thingy2.jpg


 

From: Ib Rasmussen
Subject: Re: Problem with 'seams' in merge.
Date: 21 May 2003 15:21:10
Message: <3ECBD239.9020103@ibras.dk>
Ken wrote:

> 
> Tor Olav Kristensen wrote:
> 
>>#macro MakeThingy...
> 
> Nice name :)

Didn't the Brits put a tax on that? :) See

http://www.ibras.dk/montypython/episode15.htm#4


/Ib


Post a reply to this message

From: Sun Tzu
Subject: Re: Problem with 'seams' in merge.
Date: 21 May 2003 16:15:06
Message: <3ecbde4a$1@news.povray.org>
Better than a Micro MakeThingy I suppose.  ;-)

"Ken" <tyl### [at] pacbellnet> wrote in message
news:3ECAAD86.BF1C2643@pacbell.net...
>
>
> Tor Olav Kristensen wrote:
>
> > #macro MakeThingy...
>
> Nice name :)
>
> --
> Ken Tyler


Post a reply to this message

From: Ken
Subject: Re: Problem with 'seams' in merge.
Date: 21 May 2003 21:43:37
Message: <3ECC2B71.F727BB5B@pacbell.net>
Sun Tzu wrote:
> 
> Better than a Micro MakeThingy I suppose.  ;-)

A fine point.

-- 
Ken Tyler


Post a reply to this message

From: simian
Subject: Re: Problem with 'seams' in merge.
Date: 22 May 2003 03:26:10
Message: <3ecc7b92$1@news.povray.org>
On Mon, 19 May 2003 21:23:35 -0400, Sun Tzu wrote:

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>

	And other strange tags. ;) 

	I read some of the responses and I don't know if this will help but most
graphics programs, Photoshop, gimp have a "make seamless" option which
will correct the general problem with seams on a sphere. But not knowing
the image you are using I can't save if that will preserve the image you
are trying to use. Another thing is you must start with a mercator
projection image else the "poles" will be "scrunched" into points at the
poles. There is no good solution for that problem.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Problem with 'seams' in merge.
Date: 22 May 2003 22:04:33
Message: <Xns93842A5E75415torolavkhotmailcom@204.213.191.226>
simian <sim### [at] localhostlocaldomain> wrote in
news:3ecc7b92$1@news.povray.org: 

...
>      I read some of the responses and I don't know if this will help
>      but most 
> graphics programs, Photoshop, gimp have a "make seamless" option which
> will correct the general problem with seams on a sphere. But not
> knowing the image you are using I can't save if that will preserve the
> image you are trying to use. Another thing is you must start with a
> mercator projection image else the "poles" will be "scrunched" into
> points at the poles. There is no good solution for that problem.


You are probably thinking of problems with mapping of
rectangular images onto spheres, while the problem with
his sphere was that it had tiny gaps (caused by roundoff
errors) between the CSG parts that forms his shape.


Tor Olav


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.