POV-Ray : Newsgroups : povray.newusers : Scaling question... Server Time
30 Jul 2024 22:17:55 EDT (-0400)
  Scaling question... (Message 3 to 12 of 22)  
<<< Previous 2 Messages Goto Latest 10 Messages Next 10 Messages >>>
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

From: Christopher James Huff
Subject: Re: Scaling question...
Date: 26 Nov 2003 19:39:27
Message: <cjameshuff-BB22F4.19373026112003@netplex.aussie.org>
In article <3fc50a5c@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> 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.

Actually, they can remain straight with a transformation that makes 
parallel lines non-parallel...scale two axii by the value of the third, 
flipping everything around at the origin. It wouldn't be an affine 
transform though, it would not be invertible (a singularity at a plane 
going through the origin where all points transform to < 0, 0, 0>), and 
it can not be expressed as a matrix.

-- 
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: Christopher James Huff
Subject: Re: Scaling question...
Date: 26 Nov 2003 19:52:37
Message: <cjameshuff-E25C5A.19504126112003@netplex.aussie.org>
In article <3fc4e32c@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. 

That isn't the only constraint...


> Although lines that were parallel before the
> transformation might not be after. 

That is another constraint. Parallel lines must transform to parallel 
lines.


> I also think it should be invertible
> as long as the point where the z scaling factor becomes zero is
> outside the object.

It doesn't work that way...the transform has a singularity, which makes 
it non-invertible.


> > To bend a tube, use a little CSG.
> 
> I'm not trying to bend a tube either. 

Well, those were just examples of commonly desired transformations that 
are not possible.


> 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?

It sounds like you are looking for a supercone shape. Look in shapes.inc 
for a macro for creating these..though you may have a hard time fitting 
it to the capping ellipsoids. This transformation can not be done 
directly in POV, you have to use either an isosurface, process a mesh, 
or do it with CSG and existing primitives. The transformations possible 
in POV are scaling (including reflection), rotation, translation, 
shearing, and combinations of these.

http://mathworld.wolfram.com/AffineTransformation.html

-- 
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

<<< Previous 2 Messages Goto Latest 10 Messages Next 10 Messages >>>

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