POV-Ray : Newsgroups : povray.general : U-bar bend - at any other angle than 90 : Re: U-bar bend - Success (and my scene) Server Time
2 Aug 2024 04:21:02 EDT (-0400)
  Re: U-bar bend - Success (and my scene)  
From: Rick Measham
Date: 24 Jan 2005 00:39:21
Message: <41f48a09$1@news.povray.org>
Tim Nikias wrote:
> Well, you could use vrotate(A,B), which rotates the vector A about the axis
> B. Use it on the base and end point of the second cylinder. If you've got
> the angle, the remaining bit is just trivial arithmetic.

Thanks Tim ... I did it another way though. However I might still look 
into your idea. I moved the object so the torii were at <0,0,0> then put 
the vertical pipe at <torus_radius,0,0>. As rotations apply to the 
zero-point, the pipe rotates to the correct location.

Here's my shopping trolley (which is the purpose of writing this macro, 
although I'll save it in an inc, ready for next time)

[BTW: Anyone who reads this, feel free to explain why rendering time 
went through the roof once I put in the intersection to trim the top off 
the vertical bars]

__SCENE__
#version 3.5;

#include "colors.inc"
#include "metals.inc"


global_settings {
   assumed_gamma 1.0
}

// ----------------------------------------

camera {
   location  <-20.0, 20, -10>
   direction 1.5*z
   right     x*image_width/image_height
   look_at   <0.0, 4.5,  -3>
}

sky_sphere {
   pigment {
     gradient y
     color_map {
       [0.0 rgb <0.6,0.7,1.0>]
       [0.7 rgb <0.0,0.1,0.8>]
     }
   }
}

light_source {
   <0, 0, 0>            // light's position (translated below)
   color rgb <1, 1, 1>  // light's color
   translate <-30, 30, -30>
}

// ----------------------------------------

plane {
   y, -1
   pigment { White * 2 }
}


#macro ubar( Bwidth, Bheight, lAngle, rAngle, barradius, curveradius)
union {
         union {
                 // Bar on the bottom of the U
                 cylinder {
                         <(Bwidth * -1) + curveradius * 2, curveradius * 
  1, 0>
                         <0,                               curveradius * 
-1, 0>
                         barradius
                 }

                 // Right Torus
                 intersection {
                         torus {
                                 curveradius
                                 barradius
                                 rotate <90, 0, 0>
                         }
                         intersection {
                                 plane {
                                         y,
                                         0
                                         rotate <0,0,90>
                                 }
                                 plane {
                                         y,
                                         0
                                         rotate <0,0,-90+rAngle>
                                 }
                         }
                 }

                 // Bar on the right
                 cylinder {
                         <curveradius,0,0>
                         <curveradius,Bheight - curveradius,0>
                         barradius
                         rotate <0,0,-90+rAngle>
                 }

                 translate <(Bwidth - curveradius * 2), 0, 0>
         }

         // Left Torus
         intersection {
                 torus {
                         curveradius
                         barradius
                         rotate <90, 0, 0>
                 }
                 intersection {
                         plane {
                                 y,
                                 0
                                 rotate <0,0,-90>
                         }
                         plane {
                                 y,
                                 0
                                 rotate <0,0,90-lAngle>
                         }
                 }
         }

         // Bar on the left
         cylinder {
                 <0-curveradius,0,0>
                 <0-curveradius,Bheight - curveradius,0>
                 barradius
                 rotate <0,0,90-lAngle>
         }
         translate <(Bwidth - (curveradius * 2)) * -0.5, curveradius, 0>

}
#end


#macro wheel( Wradius, Wthickness )
union {
         cylinder {
                 <Wthickness * -0.51, Wradius, 0>
                 <Wthickness * +0.51, Wradius, 0>
                 Wradius * 0.95
                 texture {
                         pigment { White }
                         finish { reflection 0.05 }
                 }
         }
         cylinder {
                 <Wthickness * -0.50, Wradius, 0>
                 <Wthickness * +0.50, Wradius, 0>
                 Wradius
                 texture {
                         pigment { Black }
                         finish { reflection 0.05 }
                 }
         }
         torus {
                 Wradius * 0.9
                 Wradius / 10
                 rotate <0,0,90>
                 translate < Wthickness * -0.5, Wradius, 0>
                 texture {
                         pigment { Black }
                         finish { reflection 0.05 }
                 }
         }
         torus {
                 Wradius * 0.9
                 Wradius / 10
                 rotate <0,0,90>
                 translate < Wthickness * +0.5, Wradius, 0>
                 texture {
                         pigment { Black }
                         finish { reflection 0.05 }
                 }
         }
      }
#end

union {
         #declare barradius = 0.025;
         #declare basketangle = 5;
         union {
    // /*  Uncomment these comments to remove the intersection that 
slows it down .. there's more below too. I think I've marked the right 
places ;)
                 intersection {
    // */
                         union {

                                 #declare Index = 1;
                                 #while( Index <= 30 )
                                 object {
                                         ubar( 5, 6, 90, 90, barradius, 
0.15 )
                                         rotate <-1*basketangle,0,0>
                                         translate <0, 0, Index * 0.25 - 
(15 * 0.25)>
                                 }
                                 #declare Index = Index + 1;
                                 #end

                                 #declare Index = -2.25;
                                 #while( Index <= 2.25 )
                                 object {
                                         ubar( 7.5 + 0.3, 6, 
90+basketangle, 90-basketangle, barradius, 0.15 )
                                         rotate <0, 90, 0>
                                         translate <Index, barradius * 
-1, 0>
                                 }
                                 #declare Index = Index + 0.25;
                                 #end


                                 rotate <basketangle,0,0>
                         }
     // /*
                         box {
                                 <-5, -1, -5>
                                 <5, 5, 5>
                         }
                 }
    // */

                 #declare Index = 0.5;
                 #while( Index < 5 )
                 object {
                         ubar( 5+barradius*2, 7.5+barradius+0.3, 90, 90, 
barradius, 0.15 )
                         rotate <90, 0, 0>
                         translate <0, Index, -3.75-0.15-barradius>
                 }
                 #declare Index = Index + 0.5;
                 #end

                 object {
                         ubar( 5+barradius*2, 7.5+barradius+0.3, 90, 90, 
barradius*2, 0.15 )
                         rotate <90, 0, 0>
                         translate <0, Index, -3.75-0.15-barradius>
                 }


                 translate <0, 3, -3.75-0.15-barradius>
         }


         difference {
                 union {
                         object {
                                 ubar(7, 8, 90, 90, 0.2, 0.5)
                                 rotate <0, 90, 0>
                                 translate <-2.55, 0, -3.3>
                         }
                         object {
                                 ubar(7, 8, 90, 90, 0.2, 0.5)
                                 rotate <0, 90, 0>
                                 translate <2.55, 0, -3.3>
                         }
                 }
                 box {
                         <-3.0, -0.1, -6.0>
                         <+3.0, 10.4, -7.7>
                 }
         }

         //front bumper
         object {
                 ubar( 2.55*2, 2, 90, 90, 0.2, 0.5)
                 rotate <90, 0, 0>
                 translate <0, 0.0, -7.5>
         }

         //handle
         object {
                 ubar( 2.55*2, 2, 90, 90, 0.2, 0.5)
                 rotate <180, 0, 0>
                 translate <0, 9.0, barradius+0.15>
         }

         translate <0, 1.6, 0>

         texture {
                 T_Chrome_2A
                 finish { reflection 0.5 }
         }

}

//handlebar
cylinder {
         <-2.0, 10.6, barradius+0.15>
         <+2.0, 10.6, barradius+0.15>
         0.25
         texture {
                 pigment { Red }
                 finish { reflection 0.25 }
         }
}



object {
         wheel(0.8, 0.25)
         translate <-2.55, 0, -0.5>
}

object {
         wheel(0.8, 0.25)
         translate < 2.55, 0, -0.5>
}

object {
         wheel(0.8, 0.25)
         translate <-2.55, 0, -6.5>
}

object {
         wheel(0.8, 0.25)
         translate < 2.55, 0, -6.5>
}
__END__


Post a reply to this message

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