POV-Ray : Newsgroups : povray.newusers : CSG and transformations Server Time
31 Oct 2024 19:29:35 EDT (-0400)
  CSG and transformations (Message 1 to 3 of 3)  
From: stevenvh
Subject: CSG and transformations
Date: 12 Jul 2007 08:25:01
Message: <web.46961d4fd8139975e99dba500@news.povray.org>
[povray virgin warning!]

Hi,
I'm trying to transform objects in some basic CSG (see code below), but I
notice that the transformation only applies to the finished CSG object.
I realize I can do the arc transformation inside the arc macro, and pass a
zillion parameters for rotating, translating, etc, but IMO that's not how
it should be. You can't foresee all possible sequential transformations.
Any help will be greatly appreciated!
Steven


-------------- code start ----------------

#macro arc (H, W, L)
union {
    cylinder { <-L / 2, W, 0>, < L / 2, W, 0>, W / 2 }
    box { <-L / 2, -.001, -W / 2>, <L / 2, W , W / 2> }
    }
#end

difference {
  box { <-50, 0, -50>, <50, 0, 50> }
  // subtract following
  arc (50, 40, 120)                     // along the x-axis
  arc (50, 40, 120) rotate y * 90       // along the z-axis

  pigment { Gray85 }
}
---------------- code end ----------------


Post a reply to this message

From: Trevor G Quayle
Subject: Re: CSG and transformations
Date: 12 Jul 2007 08:40:02
Message: <web.46962003bd021cb9c150d4c10@news.povray.org>
"stevenvh" <nomail@nomail> wrote:
> #macro arc (H, W, L)
> union {
>     cylinder { <-L / 2, W, 0>, < L / 2, W, 0>, W / 2 }
>     box { <-L / 2, -.001, -W / 2>, <L / 2, W , W / 2> }
>     }
> #end
>
> difference {
>   box { <-50, 0, -50>, <50, 0, 50> }
>   // subtract following
>   arc (50, 40, 120)                     // along the x-axis
>   arc (50, 40, 120) rotate y * 90       // along the z-axis
>
>   pigment { Gray85 }
> }
> ---------------- code end ----------------

Assuming I know what you want to do try invoking your macro within an
object{} block (or even union{} block):

object{arc (50, 40, 120) rotate y * 90}

Then any transforms are isolated from the rest of the object and you don't
need to pass any variables.


-tgq


Post a reply to this message

From: stevenvh
Subject: Re: CSG and transformations
Date: 12 Jul 2007 08:50:02
Message: <web.46962365bd021cb9e99dba500@news.povray.org>
That's it exactly. Thanks, Trevor.
(and quick reply as well!)


Post a reply to this message

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