POV-Ray : Newsgroups : povray.general : isosurface question Server Time
6 Nov 2024 02:22:04 EST (-0500)
  isosurface question (Message 1 to 4 of 4)  
From: Rafal 'Raf256' Maj
Subject: isosurface question
Date: 11 Nov 2002 09:35:26
Message: <Xns92C39DE60A80raf256com@204.213.191.226>
Hellow, I have some isosurface function fun(x,y,z) that "starts" in <0,0,0> 
and ends in <0,1,0> (i.e. an isosurface cylinder <0,0,0>-<0,1,0>)

how can I transform this isosurface to get shape that starts in W1 and ends 
in W2 ? 
I need to transform the formula, not to use rotate, translate etc...

it would be something like
#declare a = W1.x + ......
fun( x*sin(a)+y*cos(a) .... )

TIA :)


-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: isosurface question
Date: 11 Nov 2002 10:45:04
Message: <web.3dcfcf59cc3f7178ba83e52a0@news.povray.org>
You can find some clues here:

http://news.povray.org/povray.general/18830/122057


Tor Olav


Rafal 'Raf256' Maj wrote:
>Hellow, I have some isosurface function fun(x,y,z) that "starts" in <0,0,0>
>and ends in <0,1,0> (i.e. an isosurface cylinder <0,0,0>-<0,1,0>)
>
>how can I transform this isosurface to get shape that starts in W1 and ends
>in W2 ?
>I need to transform the formula, not to use rotate, translate etc...
>
>it would be something like
>#declare a = W1.x + ......
>fun( x*sin(a)+y*cos(a) .... )
>
>TIA :)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: isosurface question
Date: 11 Nov 2002 13:10:07
Message: <web.3dcff167cc3f7178edbc6d4c0@news.povray.org>
I have put some code below that transforms a
function without using transformation keywords.

Tor Olav


Tor Olav Kristensen wrote:
>You can find some clues here:
>
>http://news.povray.org/povray.general/18830/122057
>
>
>Tor Olav
>
>
>Rafal 'Raf256' Maj wrote:
>>Hellow, I have some isosurface function fun(x,y,z) that "starts" in <0,0,0>
>>and ends in <0,1,0> (i.e. an isosurface cylinder <0,0,0>-<0,1,0>)
>>
>>how can I transform this isosurface to get shape that starts in W1 and ends
>>in W2 ?
>>I need to transform the formula, not to use rotate, translate etc...
>>
>>it would be something like
>>#declare a = W1.x + ......
>>fun( x*sin(a)+y*cos(a) .... )
>>
>>TIA :)
>


// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Copyright 2002 by Tor Olav Kristensen
// Email: t o r _ o l a v _ k [ a t ] h o t m a i l [ d o t ] c o m
// http://home.no/t-o-k/povray
// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#version 3.5;

#include "colors.inc"
#include "functions.inc"

// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

// Declare function for the shape to be transformed
#declare AnyFn = function { f_torus(x, y/3, z, 3, 0.5) }

// The sample transformation to be done is
// a 60 degree rotation around the x-axis

// ===== 1 ======= 3 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Now you can do it in a hard way

#declare Angle = radians(60);

// "Matrix" for rotation around the x-axis
#declare vX = <           1,           0,           0>;
#declare vY = <           0,  cos(Angle),  sin(Angle)>;
#declare vZ = <           0, -sin(Angle),  cos(Angle)>;

// Invert matrix
#declare Det = vdot(vX, vcross(vY, vZ));
#declare vA = vcross(vY, vZ)/Det;
#declare vB = vcross(vZ, vX)/Det;
#declare vC = vcross(vX, vY)/Det;

// Extract matrix elements
#declare Ax = vA.x; #declare Ay = vA.y; #declare Az = vA.z;
#declare Bx = vB.x; #declare By = vB.y; #declare Bz = vB.z;
#declare Cx = vC.x; #declare Cy = vC.y; #declare Cz = vC.z;

// Multiply location vector with matrix
#declare TransformedFn =
  function {
    AnyFn(
      x*Ax + y*Ay + z*Az,
      x*Bx + y*By + z*Bz,
      x*Cx + y*Cy + z*Cz
    )
  }

// Use transformed function
isosurface {
  function { TransformedFn(x, y, z) }
  contained_by { sphere { <0, 0, 0>, 5 } }
  pigment { color White }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Or in a simpler way

/*
// Define a useful macro
#macro TransformFunction(Fn, Transform)

  #local TT = function { transform { Transform inverse } }

  function { Fn(TT(x, y, z).x, TT(x, y, z).y, TT(x, y, z).z) }

#end // macro TransformFunction


// Transform the function
#declare TheTransformedFunction =
  TransformFunction(
    function { AnyFn(x, y, z) },
    transform { rotate 60*x }
  )

// Use transformed function
isosurface {
  function { TheTransformedFunction(x, y, z) }
  contained_by { sphere { <0, 0, 0>, 5 } }
  pigment { color rgb <1.0, 0.9, 0.8> }
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color Blue/2 }

light_source {
  <-2, 2, -1>*100
  color White
  shadowless
}

camera {
  location <0, 10, -16>
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Christoph Hormann
Subject: Re: isosurface question
Date: 11 Nov 2002 13:47:20
Message: <3DCFFB38.1CB15DF6@gmx.de>
Tor Olav Kristensen wrote:
> 
> I have put some code below that transforms a
> function without using transformation keywords.
> 
> [...]

BTW the IsoCSG library contains macros for both variations too.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 02 Nov. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

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