POV-Ray : Newsgroups : povray.newusers : Scaling question... Server Time
26 Nov 2024 19:30:54 EST (-0500)
  Scaling question... (Message 1 to 10 of 22)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Carl Hoff
Subject: Scaling question...
Date: 25 Nov 2003 20:24:54
Message: <3fc400e6@news.povray.org>
Can anyone help me out here?

I'm trying to scale a shape in the z-direction but I want the scaling factor
to be a function of x.
Say for example I have the following cone:

cone {<0,0,0>, 5 <10,0,0>, 20}

And I want to take this shape and scale the such that the left (looking in
from -z) of the cone is scaled by 2*z and the right by 0.5*z so that when
viewed from above (the +y direction) the crosssection is a rectangle with
sides at + and - 10*z.

So far I haven't been able to insert a function into a scale command or a
matrix command.  This may be just a syntax question but I've been unable to
find my answer in the documentation.  I'd like to be able to do something
like:

 scale <1,1, -0.15*x+2>

Thanks if you can point me in the correct direction,
Carl


Post a reply to this message

From: Warp
Subject: Re: Scaling question...
Date: 25 Nov 2003 21:03:06
Message: <3fc409da@news.povray.org>
Only linear transformations are possible with transformation matrices
(scales, rotates and translates are just shortcuts to equivalent
transformation matrices).
  What you are trying to achieve is a non-linear transformation which
is not possible with matrices.

  The way to go is most probably to create the cone as an isosurface
and then modify the input variables of the isosurface function
appropriately.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Scaling question...
Date: 25 Nov 2003 21:40:24
Message: <cjameshuff-57BCFF.21392025112003@netplex.aussie.org>
In article <3fc409da@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   Only linear transformations are possible with transformation matrices
> (scales, rotates and translates are just shortcuts to equivalent
> transformation matrices).
>   What you are trying to achieve is a non-linear transformation which
> is not possible with matrices.

A small terminology correction: the transformations POV-Ray can handle 
are affine transforms. Rotate, scale, and shear are linear transforms, 
translation is an affine transform. All linear transforms are affine 
transforms. You're right in that what he's trying to accomplish is a 
non-linear transform.

To go into more detail, linear transforms have the property that 
transforming two points and adding them together gives the same result 
as adding them together and then transforming that point. Affine 
transforms such as those used by POV do not necessarily have this 
property, though they must preserve collinearity (all points on a 
straight line must transform to points on a straight line). In the case 
of POV, they must also be invertible, you will get an error about a 
"singular matrix" otherwise.


>   The way to go is most probably to create the cone as an isosurface
> and then modify the input variables of the isosurface function
> appropriately.

Or just create the transformed version directly. Don't try to transform 
a cylinder into a cone, just create a cone. To bend a tube, use a little 
CSG. Or make a mesh and deform it, which is likely to be faster than an 
isosurface, but will have problems with typical mesh artifacts like 
faceting and polygonal edges.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Mike Williams
Subject: Re: Scaling question...
Date: 25 Nov 2003 23:27:39
Message: <FsgJnBAGpCx$EwP7@econym.demon.co.uk>
Wasn't it Warp who wrote:
>  Only linear transformations are possible with transformation matrices
>(scales, rotates and translates are just shortcuts to equivalent
>transformation matrices).
>  What you are trying to achieve is a non-linear transformation which
>is not possible with matrices.
>
>  The way to go is most probably to create the cone as an isosurface
>and then modify the input variables of the isosurface function
>appropriately.

There's an example of a non-linearly scaled sphere in my isosurface
tutorial:

<http://www.econym.demon.co.uk/isotut/substitute.htm#nls>



-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Carl Hoff
Subject: Re: Scaling question...
Date: 26 Nov 2003 12:12:31
Message: <3fc4deff@news.povray.org>
Thanks.  I'm glad it wasn't just me fighting a syntax problem though if it
had I guess that would have been the easiest to fix.

I've only been playing with POV-Ray now for about 2 months and as
yet haven't got to the point of playing with isosurfaces.  I guess its time
to learn.

If someone beats me to the bunch... what I'm trying now to find is the
equation I need to use for an isosurface that looks like:

(y/a1)^2+(z/b1)^2=1   in the x=0 plane

and

(y/a2)^2+(z/b2)^2=1   in the x=x0 plane

For my cases b1=b2 but I guess I should write this as general as possible.

I think the "contained_by" should be:

box {<0,+(max(a1,a2)),+(max(b1,b2))>,
        <x0,-(max(a1,a2)),-(max(b1,b2))>}

I'm not so sure about the threshold, accuracy, or max_gradient but I
think I'll get an idea once I start playing.

Thanks...
Carl

"Warp" <war### [at] tagpovrayorg> wrote in message
news:3fc409da@news.povray.org...
>   Only linear transformations are possible with transformation matrices
> (scales, rotates and translates are just shortcuts to equivalent
> transformation matrices).
>   What you are trying to achieve is a non-linear transformation which
> is not possible with matrices.
>
>   The way to go is most probably to create the cone as an isosurface
> and then modify the input variables of the isosurface function
> appropriately.
>
> -- 
> #macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb
M()}}
> N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
> N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  -
Warp -


Post a reply to this message

From: Carl Hoff
Subject: Re: Scaling question...
Date: 26 Nov 2003 12:30:20
Message: <3fc4e32c@news.povray.org>
> To go into more detail, linear transforms have the property that
> transforming two points and adding them together gives the same result
> as adding them together and then transforming that point. Affine
> transforms such as those used by POV do not necessarily have this
> property, though they must preserve collinearity (all points on a
> straight line must transform to points on a straight line). In the case
> of POV, they must also be invertible, you will get an error about a
> "singular matrix" otherwise.

I think what I'm trying to do would keep all strait lines as strait lines
after the transformation.  Although lines that were parallel before the
transformation might not be after.  I also think it should be invertible
as long as the point where the z scaling factor becomes zero is
outside the object.

> Or just create the transformed version directly. Don't try to transform
> a cylinder into a cone, just create a cone.

Well what I'm after isn't a cylinder or a cone, though it might be easier
to transform a cylinder into the shape I'm after then a cone come to
think of it.

> To bend a tube, use a little CSG.

I'm not trying to bend a tube either.  You know how a cone can be
used to connect two spheres to make a shape like you'd get with a
linear sphere_sweep.  I'm trying to connect these two spheres with a
similar shape.

sphere {<0,0,0>,a1 scale <1,1,b1/a1>}
sphere {<x0,0,0>a2 scale <1,1,b2/a2>}

Does that make it any clearer what I'm trying to do?

> Or make a mesh and deform it, which is likely to be faster than an
> isosurface, but will have problems with typical mesh artifacts like
> faceting and polygonal edges.

I haven't got around to playing with meshs either and as I don't want
to deal with the artifacts you mention I think I'll continue to work on
the isosurface approach.

Thanks...
Carl


Post a reply to this message

From: Carl Hoff
Subject: Re: Scaling question...
Date: 26 Nov 2003 12:51:27
Message: <3fc4e81f@news.povray.org>
Thanks... I need all the tutorials I can find.  However yours
leaves me a little confused...

In your example you have:

#declare  P = function {x*x + y + z*z - 1}

isosurface {
  function { P(x,y*(1.05-y/5),z) }
  ...

Should P be the formula of a sphere?  In which case shouldn't
the function be x*x+y*y+z*z-1?  If that's not a typo I'm really
confused.  Hmmm... ok after looking closer I see you are substituting
in a y*y term for y when you call the function.  But that leaves me
wondering why you only scaled one of the y's?  I'm now curious how
that differes from:

#declare  P = function {x*x + y*y + z*z - 1}

isosurface {
  function { P(x,(1.05-y/5),z) }
  ...

I'll try it and find out.

Also... a more general question...

Is there a difference between these two as used in an isosurface?

#declare  P = function {x*x + y*y + z*z - 1}
isosurface {
  function { P(x,y,z) }
  threshold 0

and

#declare  P = function {x*x + y*y + z*z}
isosurface {
  function { P(x,y,z) }
  threshold 1

Thanks,
Carl



"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:FsgJnBAGpCx$EwP7@econym.demon.co.uk...
> Wasn't it Warp who wrote:
> >  Only linear transformations are possible with transformation matrices
> >(scales, rotates and translates are just shortcuts to equivalent
> >transformation matrices).
> >  What you are trying to achieve is a non-linear transformation which
> >is not possible with matrices.
> >
> >  The way to go is most probably to create the cone as an isosurface
> >and then modify the input variables of the isosurface function
> >appropriately.
>
> There's an example of a non-linearly scaled sphere in my isosurface
> tutorial:
>
> <http://www.econym.demon.co.uk/isotut/substitute.htm#nls>
>
>
>
> -- 
> Mike Williams
> Gentleman of Leisure


Post a reply to this message

From: Mike Williams
Subject: Re: Scaling question...
Date: 26 Nov 2003 13:31:18
Message: <tRhT4BABBPx$EwZT@econym.demon.co.uk>
Wasn't it Carl Hoff who wrote:
>Thanks... I need all the tutorials I can find.  However yours
>leaves me a little confused...
>
>In your example you have:
>
>#declare  P = function {x*x + y + z*z - 1}
>
>isosurface {
>  function { P(x,y*(1.05-y/5),z) }
>  ...
>
>Should P be the formula of a sphere?  In which case shouldn't
>the function be x*x+y*y+z*z-1?  If that's not a typo I'm really
>confused.

Yes it's a typo. it should be y*y


>Also... a more general question...
>
>Is there a difference between these two as used in an isosurface?
>
>#declare  P = function {x*x + y*y + z*z - 1}
>isosurface {
>  function { P(x,y,z) }
>  threshold 0
>
>and
>
>#declare  P = function {x*x + y*y + z*z}
>isosurface {
>  function { P(x,y,z) }
>  threshold 1

There's no difference. Since I have a mathematical background I'm more
used to dealing with thinking about the first form.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Mike Williams
Subject: Re: Scaling question...
Date: 26 Nov 2003 14:29:02
Message: <XBNd8GAw6Px$Ew+j@econym.demon.co.uk>
Wasn't it Carl Hoff who wrote:
>Thanks.  I'm glad it wasn't just me fighting a syntax problem though if it
>had I guess that would have been the easiest to fix.
>
>I've only been playing with POV-Ray now for about 2 months and as
>yet haven't got to the point of playing with isosurfaces.  I guess its time
>to learn.
>
>If someone beats me to the bunch... what I'm trying now to find is the
>equation I need to use for an isosurface that looks like:
>
>(y/a1)^2+(z/b1)^2=1   in the x=0 plane
>
>and
>
>(y/a2)^2+(z/b2)^2=1   in the x=x0 plane
>


#declare aa=max(a1,a2);
#declare bb=max(b1,b2);
isosurface {
  function {    
      pow((y/(a1+(a2-a1)*x/x0)),2)
     +pow((z/(b1+(b2-b1)*x/x0)),2)
     -1 
  }
  max_gradient 2.8
  contained_by{box{<0,-aa,-bb><x0,aa,bb>}}
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Warp
Subject: Re: Scaling question...
Date: 26 Nov 2003 15:17:32
Message: <3fc50a5c@news.povray.org>
Carl Hoff <hof### [at] wtnet> wrote:
> I think what I'm trying to do would keep all strait lines as strait lines
> after the transformation.  Although lines that were parallel before the
> transformation might not be after.

  Nope. If parallel lines do not keep parallel after the transformation,
then there exist lines which do not keep straight after the transformation.

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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