POV-Ray : Newsgroups : povray.general : help on twisted prims Server Time
29 Jul 2024 18:19:57 EDT (-0400)
  help on twisted prims (Message 1 to 7 of 7)  
From: Paulo Mota
Subject: help on twisted prims
Date: 8 Jan 2011 08:00:01
Message: <web.4d285eca8d89935e4de5fadf0@news.povray.org>
Can some one help me on the povray code to make the following solid:
A rectangle defined on the xz plane (with two opposite corners <-h,0,-m> and
<h,0,m>)
is sweeped (by a thickness e) and rotated (by an angle a) along the y axis.

Regards,
Paulo Mota


Post a reply to this message

From: Florian Siegmund
Subject: Re: help on twisted prims
Date: 8 Jan 2011 09:10:01
Message: <web.4d286f1010b5ffce2bbb5c0@news.povray.org>
"Paulo Mota" <pmo### [at] gmailcom> wrote:
> Can some one help me on the povray code to make the following solid:
> A rectangle defined on the xz plane (with two opposite corners <-h,0,-m> and
> <h,0,m>)
> is sweeped (by a thickness e) and rotated (by an angle a) along the y axis.
>
> Regards,
> Paulo Mota

You could use an isosurface to get what you are looking for...

I wrote a little scene code that does exactly that:

camera {
    location <0.75, 0.5, -1>*7
    up y
    right 4/3*x
    look_at 0
    angle 27
}

light_source {<1, 2.5, -2>*10  color rgb 1}

#declare x_h = 0.75; // half of width
#declare y_e = 1.25; // height
#declare z_m = 0.25; // half of length
#declare r_a = 135;  // rotation angle (degrees)

#declare func_box = function {max (abs (x) - x_h, abs (y - y_e/2) - y_e/2, abs
(z) - z_m)}

#declare r_a_rad_y = radians (r_a)/y_e;
#declare func_twist = function {func_box (x*cos (y*r_a_rad_y) - z*sin
(y*r_a_rad_y), y, x*sin (y*r_a_rad_y) + z*cos (y*r_a_rad_y))}

#declare twisted_box_iso =
isosurface {
    function {func_twist (x, y, z)}
    contained_by {box {-2, 2}}
    max_gradient 3
}

object {
    twisted_box_iso
    pigment {
        wrinkles
        color_map {
            [0  color rgb y]
            [1  color rgb z]
        }
    }
    finish {phong 0.5}
}

plane {
    y, 0
    pigment {checker  color rgb <0.8, 0.2, 0.1>  color rgb <1, 0.3, 0.1>}
    finish {diffuse 0.25  reflection {0.3}}
}

Regards,
Florian


Post a reply to this message

From: Alain
Subject: Re: help on twisted prims
Date: 8 Jan 2011 18:53:51
Message: <4d28f90f$1@news.povray.org>

> Can some one help me on the povray code to make the following solid:
> A rectangle defined on the xz plane (with two opposite corners<-h,0,-m>  and
> <h,0,m>)
> is sweeped (by a thickness e) and rotated (by an angle a) along the y axis.
>
> Regards,
> Paulo Mota
>
>
>

As ther is no twisted primitive and no twisting transformation, you 
ether need to use an isosurface as Florian mentioned, or use some 
external modeler to create a mesh of your twisted prism.

You can also do an approximation by stacking many very thin normal 
prisms, each slightly rotated relative to the one under it.




Alain


Post a reply to this message

From: Warp
Subject: Re: help on twisted prims
Date: 9 Jan 2011 03:46:50
Message: <4d2975fa@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:
> You can also do an approximation by stacking many very thin normal 
> prisms, each slightly rotated relative to the one under it.

  Wouldn't a box be more efficient?

-- 
                                                          - Warp


Post a reply to this message

From: Paulo Mota
Subject: Re: help on twisted prims
Date: 9 Jan 2011 06:55:01
Message: <web.4d29a0d910b5ff4de5fadf0@news.povray.org>
Dear Florian:

Thank you for your help.
My first attempt was to stack small parallelepipeds rotated by small angles.
Your solution gives a much better rendering.

I am new to pov-ray; so I still have a question: is your object solid? That is,
can it be subject to the difference operator?

Regards
Paulo Mota

> "Paulo Mota" <pmo### [at] gmailcom> wrote:
> > Can some one help me on the povray code to make the following solid:
> > A rectangle defined on the xz plane (with two opposite corners <-h,0,-m> and
> > <h,0,m>)
> > is sweeped (by a thickness e) and rotated (by an angle a) along the y axis.
> >
> > Regards,
> > Paulo Mota
>
> You could use an isosurface to get what you are looking for...
>
> I wrote a little scene code that does exactly that:
>
> camera {
>     location <0.75, 0.5, -1>*7
>     up y
>     right 4/3*x
>     look_at 0
>     angle 27
> }
>
> light_source {<1, 2.5, -2>*10  color rgb 1}
>
> #declare x_h = 0.75; // half of width
> #declare y_e = 1.25; // height
> #declare z_m = 0.25; // half of length
> #declare r_a = 135;  // rotation angle (degrees)
>
> #declare func_box = function {max (abs (x) - x_h, abs (y - y_e/2) - y_e/2, abs
> (z) - z_m)}
>
> #declare r_a_rad_y = radians (r_a)/y_e;
> #declare func_twist = function {func_box (x*cos (y*r_a_rad_y) - z*sin
> (y*r_a_rad_y), y, x*sin (y*r_a_rad_y) + z*cos (y*r_a_rad_y))}
>
> #declare twisted_box_iso =
> isosurface {
>     function {func_twist (x, y, z)}
>     contained_by {box {-2, 2}}
>     max_gradient 3
> }
>
> object {
>     twisted_box_iso
>     pigment {
>         wrinkles
>         color_map {
>             [0  color rgb y]
>             [1  color rgb z]
>         }
>     }
>     finish {phong 0.5}
> }
>
> plane {
>     y, 0
>     pigment {checker  color rgb <0.8, 0.2, 0.1>  color rgb <1, 0.3, 0.1>}
>     finish {diffuse 0.25  reflection {0.3}}
> }
>
> Regards,
> Florian


Post a reply to this message

From: Florian Siegmund
Subject: Re: help on twisted prims
Date: 9 Jan 2011 12:00:01
Message: <web.4d29e91a10b5ff699f92c50@news.povray.org>
"Paulo Mota" <pmo### [at] gmailcom> wrote:
> Dear Florian:
>
> Thank you for your help.
> My first attempt was to stack small parallelepipeds rotated by small angles.
> Your solution gives a much better rendering.
>
> I am new to pov-ray; so I still have a question: is your object solid? That is,
> can it be subject to the difference operator?
>
> Regards
> Paulo Mota
>

Yes, isosurfaces are solids that have a defined in- and outside.
But for being able to use an isosurface inside a CSG operation you have to add
"max_trace" followed by an integer or the keyword "all_intersections" to the
isosurface statement. You can read the documentation for details, if you like.

Regards,
Florian


Post a reply to this message

From: Alain
Subject: Re: help on twisted prims
Date: 9 Jan 2011 17:04:27
Message: <4d2a30eb$1@news.povray.org>

> Alain<aze### [at] qwertyorg>  wrote:
>> You can also do an approximation by stacking many very thin normal
>> prisms, each slightly rotated relative to the one under it.
>
>    Wouldn't a box be more efficient?
>

It would for a rectangular section. If the section is not rectangular, 
or you have more sides, then using stacked boxes won't do.


Alain


Post a reply to this message

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