POV-Ray : Newsgroups : povray.newusers : Scale by axis? Server Time
29 Oct 2024 22:44:45 EDT (-0400)
  Scale by axis? (Message 1 to 8 of 8)  
From: jberry02
Subject: Scale by axis?
Date: 31 May 2010 22:20:00
Message: <web.4c046e3a76d75e3fbba8fbcd0@news.povray.org>
Hello!

     Is there a way to scale an object along a specified axis?  I.e., at x=0,
the object would be scaled x*0, at x=0.3, it would be scaled x*0.3, etc.

Joe


Post a reply to this message

From: Alain
Subject: Re: Scale by axis?
Date: 31 May 2010 22:44:22
Message: <4c047406@news.povray.org>

> Hello!
>
>       Is there a way to scale an object along a specified axis?  I.e., at x=0,
> the object would be scaled x*0, at x=0.3, it would be scaled x*0.3, etc.
>
> Joe
>
>
>

You can only scale uniformly. Also, you can't scale by zero. The idea is 
that ANY line traced through the object must remain a line after any 
scaling, even if it's lenght and orientation have changed.
That's for normal objects made using primitives, including any mesh.

There is a way to have some non-uniform scaling, but it's more complicated.
For that, you need to use an isosurface equivalent to your object and 
work on the function used to represent it.
Once the function is set, you can have some fun:
you can call the function with non-constant parameters, as this:
My_Function(sin(x),y,z)
My_Function(sqrt(x),y,z)
My_Function(pow(x,3),y,z)
You can do that on all 3 axis:
My_Function(sqrt(x), pow(y,2), z+f_noise())

You can also work on an axis parameter inside the function itself.



Alain


Post a reply to this message

From: Stephen
Subject: Re: Scale by axis?
Date: 1 Jun 2010 08:15:32
Message: <4c04f9e4$1@news.povray.org>
On 01/06/2010 3:44 AM, Alain wrote:
> You can only scale uniformly.

Are you sure about that? I was under the impression that you could scale 
<x, y, z> ;-)

> Also, you can't scale by zero.

Now this is true but you can scale by 0.000001

How about?

#declare My_Location = <x, y, z> ;

object {
    OBJECT_IDENTIFIER
scale  My_Location + 0.000001
translate My_Location
  }


-- 

Best Regards,
	Stephen


Post a reply to this message

From: Alain
Subject: Re: Scale by axis?
Date: 1 Jun 2010 16:13:28
Message: <4c0569e8$1@news.povray.org>

> On 01/06/2010 3:44 AM, Alain wrote:
>> You can only scale uniformly.
>
> Are you sure about that? I was under the impression that you could scale
> <x, y, z> ;-)
The question was about non-uniform scaling along an axis. There is 
nothing that prevent you from scaling diferently for each axis.
Any straight line through the object will remain straight after that 
kind of scaling.

>
>> Also, you can't scale by zero.
>
> Now this is true but you can scale by 0.000001
>
> How about?
>
> #declare My_Location = <x, y, z> ;
>
> object {
> OBJECT_IDENTIFIER
> scale My_Location + 0.000001
> translate My_Location
> }
>
>
In that sample, the scale depends on the current value of the location, 
but remains constant for the whole object.
When the object is located close to the origin, it's scaled small, and 
large far away from the origin. By the way, you still can have a scaling 
by zero. What about My_Location = <-0.000001, -0.000001, -0.000001>?


Alain


Post a reply to this message

From: Warp
Subject: Re: Scale by axis?
Date: 2 Jun 2010 00:57:11
Message: <4c05e4a7@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:
> There is a way to have some non-uniform scaling, but it's more complicated.
> For that, you need to use an isosurface equivalent to your object and 
> work on the function used to represent it.

  Every time non-linear transformation of object comes up, isosurfaces are
suggested. However, isosurfaces are a viable solution in only very limited
cases. You can't simply take a complex CSG object and convert it to an
isosurface. Some objects are simply too complex, or have too much detail
in them in order to be renderable in a rational amount of time as an
isosurface (especially given that applying a non-linear transformation to
it will usually make it even slower to render). Texturing can also sometimes
pose a problem in certain cases, such as when different parts of the object
uses different textures, or they use texturing options not available for
isosurfaces (such as uv-mapping).

  The most efficient and versatile solution would be to use a triangle mesh.
While technically speaking triangle meshes cannot be transformed non-linearly
either, this can be approximated by subdividing the mesh into smaller triangles
and transforming the vertex points (which is basically what all mesh-based
renderers do).

  Of course POV-Ray itself offers little to no tools to create and modify
meshes in this way, so the only option is, basically, to use a third-party
mesh modeling tool to create the mesh.

  There exist some mesh subdivision&transformation macros out there, but
they all assume that you have the vertex points in an array (as it's
currently not possible to extract the vertex points from a mesh object).

-- 
                                                          - Warp


Post a reply to this message

From: Stephen
Subject: Re: Scale by axis?
Date: 2 Jun 2010 02:41:32
Message: <4c05fd1c$1@news.povray.org>
On 01/06/2010 9:13 PM, Alain wrote:

>> On 01/06/2010 3:44 AM, Alain wrote:
>>> You can only scale uniformly.
>>
>> Are you sure about that? I was under the impression that you could scale
>> <x, y, z> ;-)
> The question was about non-uniform scaling along an axis. There is
> nothing that prevent you from scaling diferently for each axis.
> Any straight line through the object will remain straight after that
> kind of scaling.
>



often (probably never) make simple mistakes. Heigh Ho! Another example 
of how PovRay keeps your mind young. ;-)
>>

>>
> In that sample, the scale depends on the current value of the location,
> but remains constant for the whole object.
> When the object is located close to the origin, it's scaled small, and
> large far away from the origin. By the way, you still can have a scaling
> by zero. What about My_Location = <-0.000001, -0.000001, -0.000001>?
>
>

Of course but this is the newusers group and I feel that there is no 
need to over complicate answers. Also as I implied above I thought that 
it was a simpler question.


-- 

Best Regards,
	Stephen


Post a reply to this message

From: jberry02
Subject: Re: Scale by axis?
Date: 2 Jun 2010 20:05:00
Message: <web.4c06f1155ba8d59dbba8fbcd0@news.povray.org>
Stephen <mca### [at] aolDOTcom> wrote:


For the sake of completeness, in case someone is reading this thread in the
future.....

Here is a fairly simple example of what I was asking about.  Take the following
snippet....

object {
  box {<-1,-1,-1>,<1,1,1>}
  scale_by_axis(y,x)
}

The hypothetical function/macro scale_by_axis would take the "y" values of the
box, and scale them by their corresponding position on the x axis.  The end
result would be two triangular prisms "joined" at the z axis (with the left half
of the box inverted due to negative scaling).

[Please note that this is *not* an example of the type of object I am interested
in creating - I choose it as a simple example of the concept.]


Post a reply to this message

From: Alain
Subject: Re: Scale by axis?
Date: 3 Jun 2010 16:37:56
Message: <4c0812a4@news.povray.org>

> Stephen<mca### [at] aolDOTcom>  wrote:

>
> For the sake of completeness, in case someone is reading this thread in the
> future.....
>
> Here is a fairly simple example of what I was asking about.  Take the following
> snippet....
>
> object {
>    box {<-1,-1,-1>,<1,1,1>}
>    scale_by_axis(y,x)
> }
>
> The hypothetical function/macro scale_by_axis would take the "y" values of the
> box, and scale them by their corresponding position on the x axis.  The end
> result would be two triangular prisms "joined" at the z axis (with the left half
> of the box inverted due to negative scaling).
>
> [Please note that this is *not* an example of the type of object I am interested
> in creating - I choose it as a simple example of the concept.]
>
>
>
That's imposible with normal objects.

For that, you need to convert that object into a mesh and deform the 
mesh or use an isosurface equivalent to your object, if such an 
isosurface is possible AND practical.

There is at least one macro that can construct a mesh out of an object.

Once the mesh have been created, it should be relatively easy to do what 
you want, but with a possible problem: part of the mesh may have 
insideness inversion.


Alain


Post a reply to this message

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