POV-Ray : Newsgroups : povray.newusers : Problems declaring objects Server Time
30 Jul 2024 08:24:44 EDT (-0400)
  Problems declaring objects (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 05:53:12
Message: <41481108$1@news.povray.org>
If I do this:
===================================
object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5 }
object { Puntos }
object { Agulles }
object { Cilindre }
==================================
I thinks that is your idea, I can not see the other object on the correct
place. If I do this:
====================================
object { Reloj rotate y*115 scale 0.5 }
object { Puntos scale 0.5 }
object { Agulles scale 0.5 }
object { Cilindre scale 0.5 }
=====================================
Some of the objects appear also moved.
I'm thinking....

Thanks,
Oleguer


mensaje news:41480a78$1@news.povray.org...
> Instead of placing everything in a union{} at the end and naming it
> Todo_Reloj, why not place the different objects by themselves and only
scale
> what needs to be scaled? Something similiar to this:
>
> object { Reloj rotate y*115 translate <0, 0, 0> no_shadow scale 0.5}
> object { Puntos  no_shadow}
> object { Agulles  no_shadow}
> object { Cilindre  no_shadow}
>
> That way, only Reloj will be scaled and the rest left untouched.
> Or, leave the #declare Todo_Reloj = union{---} around all the objects, but
> just scale the one needing to be scaled.
>
> Regards,
> Tim
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 06:25:25
Message: <41481895@news.povray.org>
> If I do this:
> ===================================
> object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5 }
> object { Puntos }
> object { Agulles }
> object { Cilindre }
> ==================================
> I thinks that is your idea, I can not see the other object on the correct
> place. If I do this:
> ====================================
> object { Reloj rotate y*115 scale 0.5 }
> object { Puntos scale 0.5 }
> object { Agulles scale 0.5 }
> object { Cilindre scale 0.5 }

Well, in your first example, you only scale Reloj, in your second example,
you scale all objects, which is just like you did before. Maybe you should
consult the Documentaion, Section 2.2.7 for some more information on
transformations.

The idea is simple: "translate" moves an object, "rotate" rotates an object
about the origin and the given axis', and "scale" scales/sizes an object in
relation to the origin (<0,0,0>). So, if an object is placed at <5,0,0> and
you scale it by .5, not only will the object's dimensions (e.g. its radius)
be sized down to half its original size, but the distance to the origin will
be sized down as well, thus placing the object at <2.5,0,0>.

Then, when you declare and union{} objects, they all get "glued" together,
so when you transform a union, all objects inside the union will get
transformed.

Now, if you want to scale an object's size, but not it's position, what do
you have to do? Let's say you've got a sphere at <5,0,0> and want to squish
it some along the x-axis, making it more disc-shaped. First, you'd have to
translate the sphere back to the origin, then you scale it, and then you
translate it back.

sphere{<5,0,0>,1
translate <-5,0,0>
scale <.25,1,1>
translate <5,0,0>
pigment{rgb 1}}

Now, for a sphere this is kinda pointless, as you could have placed it at
the origin from the beginning and thus save translating it back to the
origin:

sphere{<0,0,0>,1
scale <.25,1,1>
translate <5,0,0>
pigment{rgb 1}}

But that's the basic idea of how to transform objects. I don't know what
exactly you're after, but if you only want to scale certain parts of an
object, then only scale those, not the entire object.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Tom Melly
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 06:26:31
Message: <414818d7$1@news.povray.org>
"Oleguer Vilella" <ole### [at] infonegociocom> wrote in message
news:41481108$1@news.povray.org...

> Some of the objects appear also moved.
> I'm thinking....

When you scale an object, the only point of the object that won't move is the
point that rests at <0,0,0> (assuming that you're scaling all axis).

To understand what is happening, try the following scene using different values
for myScale. Note that we divide the radius of the spheres by the value of
myScale. This means that the scale size doesn't affect the radius of the
spheres, only their positions.

camera {
  location  <0.0, 0.0, -10.0>
  look_at   <0.0, 0.0,  0.0>
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

#declare myScale = 1;

sphere{
  0,0.25/myScale
  scale myScale
  pigment{rgb<1,0,0>}
}

sphere{
  1,0.25/myScale
  scale myScale
  pigment{rgb<0,1,0>}
}


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 09:41:51
Message: <4148469f@news.povray.org>
Hello Tim,

I want to make all the object smaler. I understood your firts exemple and I
trayed it, but I don't understand your second exemple. You says:
=============
sphere{<0,0,0>,1
scale <.25,1,1>
translate <5,0,0>
pigment{rgb 1}}
=============
With the scale <.25, 1, 1>, how do you calculate the translate <5, 0, 0>?
If I put scale 5, how can I know the translate vector?

"for a sphere this is kinda pointless, as you could have placed it at the
origin from the beginning and thus save translating it back to the origin:"
Can you tray to explain me it again, please?

Thank you very much,
Oleguer



mensaje news:41481895@news.povray.org...
> > If I do this:
> > ===================================
> > object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5 }
> > object { Puntos }
> > object { Agulles }
> > object { Cilindre }
> > ==================================
> > I thinks that is your idea, I can not see the other object on the
correct
> > place. If I do this:
> > ====================================
> > object { Reloj rotate y*115 scale 0.5 }
> > object { Puntos scale 0.5 }
> > object { Agulles scale 0.5 }
> > object { Cilindre scale 0.5 }
>
> Well, in your first example, you only scale Reloj, in your second example,
> you scale all objects, which is just like you did before. Maybe you should
> consult the Documentaion, Section 2.2.7 for some more information on
> transformations.
>
> The idea is simple: "translate" moves an object, "rotate" rotates an
object
> about the origin and the given axis', and "scale" scales/sizes an object
in
> relation to the origin (<0,0,0>). So, if an object is placed at <5,0,0>
and
> you scale it by .5, not only will the object's dimensions (e.g. its
radius)
> be sized down to half its original size, but the distance to the origin
will
> be sized down as well, thus placing the object at <2.5,0,0>.
>
> Then, when you declare and union{} objects, they all get "glued" together,
> so when you transform a union, all objects inside the union will get
> transformed.
>
> Now, if you want to scale an object's size, but not it's position, what do
> you have to do? Let's say you've got a sphere at <5,0,0> and want to
squish
> it some along the x-axis, making it more disc-shaped. First, you'd have to
> translate the sphere back to the origin, then you scale it, and then you
> translate it back.
>
> sphere{<5,0,0>,1
> translate <-5,0,0>
> scale <.25,1,1>
> translate <5,0,0>
> pigment{rgb 1}}
>
> Now, for a sphere this is kinda pointless, as you could have placed it at
> the origin from the beginning and thus save translating it back to the
> origin:
>
> sphere{<0,0,0>,1
> scale <.25,1,1>
> translate <5,0,0>
> pigment{rgb 1}}
>
> But that's the basic idea of how to transform objects. I don't know what
> exactly you're after, but if you only want to scale certain parts of an
> object, then only scale those, not the entire object.
>
> Regards,
> Tim
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 09:58:24
Message: <41484a80@news.povray.org>
> With the scale <.25, 1, 1>, how do you calculate the translate <5, 0, 0>?
> If I put scale 5, how can I know the translate vector?

That's actually pretty simple: first, Povray scales the object, afterwards
it translates it to <5,0,0>. Since the sphere is already located at the
origin, the position of the sphere won't change when scaling it. Thus, it
will be squashed a little, but still be positioned at <0,0,0>. So, if I want
to place the sphere at <5,0,0>, I just have to translate it there.

> "for a sphere this is kinda pointless, as you could have placed it at the
> origin from the beginning and thus save translating it back to the
origin:"
> Can you tray to explain me it again, please?

The same as above: positions of objects only change when they are not
centered at the origin, since scaling would not only scale the object, but
also its distance to the origin.
The sphere requires a center vector and a radius. If the center vector is
<0,0,0>, the sphere is sitting right on the origin, and scaling it will only
affect the size.

But, if you place the center of the sphere somewhere else, scaling would
also affect the position/center of the sphere. Hence, we need to move it to
the origin first, scale it, and move it back, if we want to retain its
position, but not its size.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 10:15:01
Message: <41484e65@news.povray.org>
Well, Tim, just a minute... I think that I'm doing it right now.


mensaje news:41484a80@news.povray.org...
> > With the scale <.25, 1, 1>, how do you calculate the translate <5, 0,
0>?
> > If I put scale 5, how can I know the translate vector?
>
> That's actually pretty simple: first, Povray scales the object, afterwards
> it translates it to <5,0,0>. Since the sphere is already located at the
> origin, the position of the sphere won't change when scaling it. Thus, it
> will be squashed a little, but still be positioned at <0,0,0>. So, if I
want
> to place the sphere at <5,0,0>, I just have to translate it there.
>
> > "for a sphere this is kinda pointless, as you could have placed it at
the
> > origin from the beginning and thus save translating it back to the
> origin:"
> > Can you tray to explain me it again, please?
>
> The same as above: positions of objects only change when they are not
> centered at the origin, since scaling would not only scale the object, but
> also its distance to the origin.
> The sphere requires a center vector and a radius. If the center vector is
> <0,0,0>, the sphere is sitting right on the origin, and scaling it will
only
> affect the size.
>
> But, if you place the center of the sphere somewhere else, scaling would
> also affect the position/center of the sphere. Hence, we need to move it
to
> the origin first, scale it, and move it back, if we want to retain its
> position, but not its size.
>
> Regards,
> Tim
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 10:26:21
Message: <4148510d$1@news.povray.org>
Hi again Tim,

I think thats right... I have changed some numbers and when I calculated the
picture, appears all on the correct position.
That's the code:
=====================================
//Per fer els punts dels quarts.
#declare Puntos = union {
sphere { <-0.3, -0.7, 0>, 0.1 pigment { color White } finish { ambient 1 }
translate <2.1, 9.7, -4> }
sphere { <-0.35, 0.15, 0>, .1 pigment { color White } finish { ambient 1 }
translate <-5.4, 9.35, -4> }
sphere { <0, 0, 0>, .1 pigment { color White } finish { ambient 1 }
translate <-2.2, 12.6, -4> }
sphere { <0, 0, 0>, .1 pigment { color White } finish { ambient 1 }
translate <-2.2, 6, -4> }
no_shadow
}
//Agulles del relotge.
#declare Agulles = union {
box { <-1, 0, -3.5> <-0.8, .2, 3.5> pigment { color Black } finish { ambient
1 } translate <-0.22, 8.2, -4> rotate <9, 0, 0> no_shadow }
box { <-1, 0, -1> <-0.8, .2, 0.5> pigment { color Black } finish { ambient
1 } translate <1.12, -0.5, -10> rotate <60, 30, 0> no_shadow }
translate y*0.5
}
//Cilindre que unix les agulles.
#declare Cilindre =
cylinder { <0, 0.9, -0.5> <0, 1, 1> 0.035 texture { T_Gold_1D } finish {
specular 2 ambient 1 diffuse .07 reflection 0 phong 0.3 phong_size 30 }
rotate y*25 rotate x*-2 translate <-3.18, 8.8, -6>
}
//Declarant les diverses parts.
#declare Todo_Reloj = union {
object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5  }
object { Puntos translate 0.5 scale 0.5 translate 0 }
object { Agulles translate 0.5 scale 0.5 translate 0 }
object { Cilindre translate 0.5 scale 0.5 translate y*0  }
no_shadow
}
//Declarant tot junt.
object { Todo_Reloj no_shadow translate y*0  }
====================================
Now I have to adjust the "Cilindre", but it's easy and quick.
Do you think that's right?

Best regards,
Oleguer


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 10:28:11
Message: <4148517b@news.povray.org>
Thank you very much, Tom, for gives me your document, it's very interesting
and it helped me to understood my problem.

Regards,
Oleguer



news:414818d7$1@news.povray.org...
> "Oleguer Vilella" <ole### [at] infonegociocom> wrote in message
> news:41481108$1@news.povray.org...
>
> > Some of the objects appear also moved.
> > I'm thinking....
>
> When you scale an object, the only point of the object that won't move is
the
> point that rests at <0,0,0> (assuming that you're scaling all axis).
>
> To understand what is happening, try the following scene using different
values
> for myScale. Note that we divide the radius of the spheres by the value of
> myScale. This means that the scale size doesn't affect the radius of the
> spheres, only their positions.
>
> camera {
>   location  <0.0, 0.0, -10.0>
>   look_at   <0.0, 0.0,  0.0>
> }
>
> light_source {
>   <0, 0, 0>            // light's position (translated below)
>   color rgb <1, 1, 1>  // light's color
>   translate <-30, 30, -30>
> }
>
> #declare myScale = 1;
>
> sphere{
>   0,0.25/myScale
>   scale myScale
>   pigment{rgb<1,0,0>}
> }
>
> sphere{
>   1,0.25/myScale
>   scale myScale
>   pigment{rgb<0,1,0>}
> }
>
>
>
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 11:00:31
Message: <4148590f$1@news.povray.org>
I've just used your scene and took a look at it. Have you tried moving the
camera?
If, for example, you place the camera at <-20,8,0> you'll notice a few
problems your clock has.

It seems to me like you are building the clock to work from a specific
angle, instead, you should try building the clock as it would be in real
world. Maybe by measuring a real clock, you can see how high certain objects
are, and how thick, etc. Another thing you should try to do is keep the code
clean and easy to understand. For example, the white dots you use to
represent 12, 3, 6 and 9 o'clock are translated multiple times before they
are at their final location.

Just take your first white sphere. It is centered at <-0.3,-0.7,0> and you
translate it by <2.1,9.7,-4>. Then, later, you reference the object and then
apply "translate 0.5 scale 0.5" to it. It would be much easier to simply
create the sphere at <0,0,0>, then position it where you want it using a
single "translate", e.g. like this:
sphere{<0,0,0>,0.1 pigment{color White}finish{ambient 1}
translate <1.8,9,-4>
}

Or, much easier, like this:
sphere{<1.8,9,-4>,0.1 pigment{color White}finish{ambient 1}}

A question that comes to mind when looking at the object and your questions
is if you properly understand the cartesian coordinate system used by
POV-Ray? This is not meant to taunt you, but a proper understanding of it
would be very useful when working with POV-Ray. Did you take a few Advanced
Geometry classes at school or college, by any chance? You'd get a good idea
of the coordinate system that way.

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 14:30:59
Message: <41488a63@news.povray.org>
Yes, you have the reason, that's very confused. Now I'm simplifing them,
because is very confused. I don't like this kind of numbers, some of them
are very big and they are multiplied a lot of times, I must reduce them.

Thank you very much,
Oleguer






mensaje news:4148590f$1@news.povray.org...
> I've just used your scene and took a look at it. Have you tried moving the
> camera?
> If, for example, you place the camera at <-20,8,0> you'll notice a few
> problems your clock has.
>
> It seems to me like you are building the clock to work from a specific
> angle, instead, you should try building the clock as it would be in real
> world. Maybe by measuring a real clock, you can see how high certain
objects
> are, and how thick, etc. Another thing you should try to do is keep the
code
> clean and easy to understand. For example, the white dots you use to
> represent 12, 3, 6 and 9 o'clock are translated multiple times before they
> are at their final location.
>
> Just take your first white sphere. It is centered at <-0.3,-0.7,0> and you
> translate it by <2.1,9.7,-4>. Then, later, you reference the object and
then
> apply "translate 0.5 scale 0.5" to it. It would be much easier to simply
> create the sphere at <0,0,0>, then position it where you want it using a
> single "translate", e.g. like this:
> sphere{<0,0,0>,0.1 pigment{color White}finish{ambient 1}
> translate <1.8,9,-4>
> }
>
> Or, much easier, like this:
> sphere{<1.8,9,-4>,0.1 pigment{color White}finish{ambient 1}}
>
> A question that comes to mind when looking at the object and your
questions
> is if you properly understand the cartesian coordinate system used by
> POV-Ray? This is not meant to taunt you, but a proper understanding of it
> would be very useful when working with POV-Ray. Did you take a few
Advanced
> Geometry classes at school or college, by any chance? You'd get a good
idea
> of the coordinate system that way.
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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