POV-Ray : Newsgroups : povray.newusers : Add twist to isosurface Server Time
22 Dec 2024 11:02:38 EST (-0500)
  Add twist to isosurface (Message 1 to 4 of 4)  
From: kurtz le pirate
Subject: Add twist to isosurface
Date: 24 Jun 2012 12:03:22
Message: <kurtzlepirate-F0C724.18032124062012@news.povray.org>
Hello,

I made a simple isosurface defined as a cylinder minus a groove :

  function { sqrt(pow(x,2) + pow(z,2)) - Groove(x,z) }

with :

  Groove = function(a,b) { R + q - 2*q*abs(cos(ang(a,b)))}


Now, a want to twist this isosurface along y axis. I found on Internet 
that, x and z must be modified with functions like this :

  TwistX = function { x*cos(a*y) - z*sin(a*y) }
  TwistZ = function { x*sin(a*y) + z*cos(a*y) }

   
ok... but how to 'put' this twist's functions 'in' my main isosurface 
function ?


this should be simple, but I can not do :(


thanks.
-- 
klp


Post a reply to this message

From: StephenS
Subject: Re: Add twist to isosurface
Date: 24 Jun 2012 17:45:01
Message: <web.4fe78a498a20243758ec92320@news.povray.org>
kurtz le pirate <kur### [at] yahoofr> wrote:
> Hello,
>
> I made a simple isosurface defined as a cylinder minus a groove :
>
>   function { sqrt(pow(x,2) + pow(z,2)) - Groove(x,z) }
>
> with :
>
>   Groove = function(a,b) { R + q - 2*q*abs(cos(ang(a,b)))}
>
>
> Now, a want to twist this isosurface along y axis. I found on Internet
> that, x and z must be modified with functions like this :
>
>   TwistX = function { x*cos(a*y) - z*sin(a*y) }
>   TwistZ = function { x*sin(a*y) + z*cos(a*y) }
>
>
> ok... but how to 'put' this twist's functions 'in' my main isosurface
> function ?
>
>
> this should be simple, but I can not do :(
>
>
> thanks.
> --
> klp
A working scene would be easier.

This is a scene I keep to help me with twisting.

****
// perspective (default) camera
camera {
  location  <0.0, 2.0, -5.0>
  look_at   <0.0, 0.0,  0.0>
  right     x*image_width/image_height
}
// create a regular point light source
light_source {
  0*x                  // light's position (translated below)
  color rgb <1,1,1>    // light's color
  translate <-20, 40, -20>
}
// sets the default texture that objects get when they have no texture specified
#default {
  texture { pigment {color red 1} finish{ambient 0.2} }
}

// Set a color of the background (sky)
background { color rgb< 1, 1, 1> }

// internal functions usable in user defined functions
// for example for isosurfaces and function pattern
#include "functions.inc"

box{<-1,-.5,-.5>,<1,.5,.5>
 //rotate<0,90,0> //for end view
 }

isosurface{
 function { max((x*x-2),(y*y-.25),(z*z-.25)) }
 contained_by { box{<-1,-1,-1>,<1,1,1>} }
 max_gradient 1.8
 //rotate<0,90,0> //for end view
 translate<0,1.5,0>
}

#declare N_turns=.125; // per pov unit
isosurface{
//function { max((x*x-2),(y*y-.25),(z*z-.25)) }
                                                    // replace y with
z*sin(x*2*pi*N) + y*cos(x*2*pi*N)
                                                    // replace z with
z*cos(x*2*pi*N) - y*sin(x*2*pi*N)
  function { max((x*x-2.),((z*sin(x*2*pi*N_turns) +
y*cos(x*2*pi*N_turns))*(z*sin(x*2*pi*N_turns) +
y*cos(x*2*pi*N_turns))-.25),((z*cos(x*2*pi*N_turns) -
y*sin(x*2*pi*N_turns))*(z*cos(x*2*pi*N_turns) - y*sin(x*2*pi*N_turns))-.25)) }
  contained_by { box{<-1,-1,-1>,<1,1,1>} }
  max_gradient 2.91
  //rotate<0,90,0> //for end view
  translate<0,-1.5,0>
}

#declare N_turns=-.125; // per pov unit, turn other direction
isosurface{
//function { max((x*x-2),(y*y-.25),(z*z-.25)) }
                                                    // replace y with
z*sin(x*2*pi*N) + y*cos(x*2*pi*N)
                                                    // replace z with
z*cos(x*2*pi*N) - y*sin(x*2*pi*N)
  function { max((x*x-2.),((z*sin(x*2*pi*N_turns) +
y*cos(x*2*pi*N_turns))*(z*sin(x*2*pi*N_turns) +
y*cos(x*2*pi*N_turns))-.25),((z*cos(x*2*pi*N_turns) -
y*sin(x*2*pi*N_turns))*(z*cos(x*2*pi*N_turns) - y*sin(x*2*pi*N_turns))-.25)) }
  contained_by { box{<-1,-1,-1>,<1,1,1>} }
  max_gradient 2.91
  //rotate<0,90,0> //for end view
  translate<2.5,-1.5,0>
}

#declare N_turns=.125; // per pov unit, also turn other direction
isosurface{
//function { max((x*x-2),(y*y-.25),(z*z-.25)) }
                                                    // replace y with
z*sin(x*2*pi*N) - y*cos(x*2*pi*N)
                                                    // replace z with
z*cos(x*2*pi*N) + y*sin(x*2*pi*N)
  function { max((x*x-2.),((z*sin(x*2*pi*N_turns) -
y*cos(x*2*pi*N_turns))*(z*sin(x*2*pi*N_turns) -
y*cos(x*2*pi*N_turns))-.25),((z*cos(x*2*pi*N_turns) +
y*sin(x*2*pi*N_turns))*(z*cos(x*2*pi*N_turns) + y*sin(x*2*pi*N_turns))-.25)) }
  contained_by { box{<-1,-1,-1>,<1,1,1>} }
  max_gradient 2.91
  //rotate<0,90,0> //for end view
  translate<-2.5,-1.5,0>
}
**** be carefull of word wrap.

for you, it might be....

//function { sqrt(pow(x,2) + pow(z,2)) - Groove(x,z) }

function { sqrt(
pow(x,2)
+ pow(z,2)
)) - Groove(x,z)
}

function { sqrt(
pow(x*cos(a*y) - z*sin(a*y),2)
+ pow(x*sin(a*y) + z*cos(a*y),2)
)) - Groove(x*cos(a*y) - z*sin(a*y),x*sin(a*y) + z*cos(a*y))
}


Hope this helps:-)

Stephen S


Post a reply to this message

From: Alain
Subject: Re: Add twist to isosurface
Date: 25 Jun 2012 12:43:54
Message: <4fe8954a$1@news.povray.org>

>
> Hello,
>
> I made a simple isosurface defined as a cylinder minus a groove :
>
>    function { sqrt(pow(x,2) + pow(z,2)) - Groove(x,z) }
>
> with :
>
>    Groove = function(a,b) { R + q - 2*q*abs(cos(ang(a,b)))}
>
>
> Now, a want to twist this isosurface along y axis. I found on Internet
> that, x and z must be modified with functions like this :
>
>    TwistX = function { x*cos(a*y) - z*sin(a*y) }
>    TwistZ = function { x*sin(a*y) + z*cos(a*y) }
>
>
> ok... but how to 'put' this twist's functions 'in' my main isosurface
> function ?
>
>
> this should be simple, but I can not do :(
>
>
> thanks.
>
One possibility would be to add that twist in the function call:

#declare Grooved_Cylinder = function { sqrt(pow(x,2) + pow(z,2)) - 
Groove(x,z) }

object{Grooved_cylinder(x*cos(a*y) - z*sin(a*y), y, x*sin(a*y) + z*cos(a*y))

This will displace the sample points passed to the function and make it 
look twisted.
To reverse the twisting direction, use -y in the sin and cos.



Alain


Post a reply to this message

From: kurtz le pirate
Subject: Re: Add twist to isosurface
Date: 1 Jul 2012 05:29:33
Message: <kurtzlepirate-F51E66.11293201072012@news.povray.org>
In article <web.4fe78a498a20243758ec92320@news.povray.org>,
 "StephenS" <nomail@nomail> wrote:

>function {
>  sqrt(pow(x*cos(a*y)-z*sin(a*y),2)+pow(x*sin(a*y)+z*cos(a*y),2))-
>  Groove(x*cos(a*y) - z*sin(a*y),x*sin(a*y) + z*cos(a*y))
>  }

thanks, it's work.

-- 
klp


Post a reply to this message

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