POV-Ray : Newsgroups : povray.general : an extraordinary rotation question Server Time
29 Nov 2026 20:23:31 EST (-0500)
  an extraordinary rotation question (Message 1 to 41 of 41)  
From: mysdn
Subject: an extraordinary rotation question
Date: 19 Jun 2009 06:10:00
Message: <web.4a3b62de84d4e97f8813d5ca0@news.povray.org>
Hello everybody,
 I'm new at this forum and very interested in ray tracing. Currently, I'm using
Povray for ray tracing. But I have a huge problem understanding its rotation
logic. Let's say I have 2 walls each 250 cm in length. Suppose we stand in
front of 1st wall and 2nd wall is attached to 1st on the right side. Now rotate
2nd wall 45 degrees AND it loses position, no more their tips are attached like
they should as an angled wall. The 2nd wall moves towards us and forward.

Obviously I don't understand rotation in povray, I do use povray for many things
for over a year but rotation always eluded me. I attached sample pov file at
http://ompf.org/forum/viewtopic.php?f=6&t=1343
If you take a look and show me some direction, I will be grateful. If you take a
look at sample, you will see it's not just a simple matter of placing objects by
just translate to <0,0,0> then rotate to .. then translate back to etc. Cause
final translation values are assigned by 2D API Piccolo. Thank you very much.

P:S This is for an app that writes SDL, so it's important.
I also read a lot about povray rotate keyword but still dont get it and I can be
considered pretty smart as the huge 2D-3D C# app I wrote will testify.

Any type of help will be greatly appreciated.
ibrahim dogan
Turkey


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 11:08:31
Message: <4a3ba9ef@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a3b62de84d4e97f8813d5ca0@news.povray.org...
> Hello everybody,
> I'm new at this forum and very interested in ray tracing. Currently, I'm 
> using
> Povray for ray tracing. But I have a huge problem understanding its 
> rotation
> logic. Let's say I have 2 walls each 250 cm in length. Suppose we stand in
> front of 1st wall and 2nd wall is attached to 1st on the right side. Now 
> rotate
> 2nd wall 45 degrees AND it loses position, no more their tips are attached 
> like
> they should as an angled wall. The 2nd wall moves towards us and forward.
>
> Obviously I don't understand rotation in povray, I do use povray for many 
> things
> for over a year but rotation always eluded me. I attached sample pov file 
> at
> http://ompf.org/forum/viewtopic.php?f=6&t=1343
> If you take a look and show me some direction, I will be grateful. If you 
> take a
> look at sample, you will see it's not just a simple matter of placing 
> objects by
> just translate to <0,0,0> then rotate to .. then translate back to etc. 
> Cause
> final translation values are assigned by 2D API Piccolo. Thank you very 
> much.
>
> P:S This is for an app that writes SDL, so it's important.
> I also read a lot about povray rotate keyword but still dont get it and I 
> can be
> considered pretty smart as the huge 2D-3D C# app I wrote will testify.
>

The standard 'rotate' operation rotates around the origin. In the case that 
you describe I think you'd need to rotate around the near left corner of the 
second wall (using that edge as a rotational axis). There is a macro in the 
"transforms.inc" file that comes with POV-Ray that will do this for you. So 
you'll need to add the line:

#include "transforms.inc"

Then you can use the "Rotate_Around_Trans(Rotation, Point)" macro in place 
of the current set of translations and rotations that you have at the end of 
your file 'rotation.pov'. You'll probably need something like the following 
code:

#declare Axis = min_extent(ek_duvar12);
object {ek_duvar12  Axis_Rotate_Trans( 45*y,Axis)}

This assumes that the point on the wall object that is furthest in the -x 
direction and the point the furthest in the -z direction adequately define 
the corner that you need to rotate around. The y value doesn't really matter 
if you're only rotating around y. However, if your wall has a rough surface, 
or protrusions such as buttresses, you may need to adjust Axis before 
passing it into the macro. You can do this by adding a vector to compensate 
for these protrusions. For example:

#declare Axis = Axis+<0.01,0,0.02>;


Regards,
Chris B.


Post a reply to this message

From: clipka
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 14:30:00
Message: <web.4a3bd891cfb6d607080f32a0@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote:
>  I'm new at this forum and very interested in ray tracing. Currently, I'm using
> Povray for ray tracing. But I have a huge problem understanding its rotation
> logic.

That's perfectly normal, I guess everyone had that :)

The key to understanding POV-Ray's rotations is that POV-Ray always (well,
*virtually* always) operates in absolute coordinate space; similarly, rotations
are always about the absolute coordinate origin.

In order to rotate an object around an arbitrary point, you need to first
translate the object so that the particular point ends up at the absolute
coordinate origin, then perform the rotation, and then translate the object
back; e.g.:

    translate -<3,2,1>
    rotate y*30
    translate <3,2,1>

will perform a 30-degree rotation about the vertical through the point <3,2,1>.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 17:35:01
Message: <web.4a3c0304cfb6d608813d5ca0@news.povray.org>
Thanks clipka and Chris B,

Chris, thanks for the explanations but transform.inc fails (yellow line) at the
second line of the macro   Axis_Rotate_Trans(Axis, Angle).

I can place objects precisely positioned when they are at 0-360, 90, 180, 270
degrees rotated by taking into account their width or height. If rotation is
0-360 or 180 I calculate width into positioning math. If rotation is 90 or 270
degrees I calculate height (or depth, speaking 2D) into positioning. And
everything is fine at those mentioned degrees of rotation. Trouble begins with
rotation values other than these.   Do I need trigonometry to calculate rotated
objects position, for example move it some points to the right or left for each
degree of object's rotation. Simply put the regular advice translate -<....>
then rotate y*45 then translate to final position doesnot work in this case. If
I knew why it didn't work maybe problem would be solved.
I bet there is a ready solution for this, Chris came close to putting his finger
on it.

I appreciate anyone's contribution, I'm reaaaaly stuck, maybe desperate. Thanks.

PS: povray version 3.6.1c


Post a reply to this message

From: Tim Attwood
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 19:02:19
Message: <4a3c18fb@news.povray.org>
For exact alignments of object you need the
correct coordinates for the desired "seam" corner.
In the example you provided one of the corners is
at <-49.999,-49.999,0.001>, and another at
<50.001,50.001,100.001>.  

The first thing you are doing with "box_"
is redeclaring it as BOX.
#declare BOX = object { box_  scale <0.01,0.01,0.01> translate <0, 0, 0> }
When you scale you are relocating the corners around the origin by
multiplication. So 
0.01*<-49.999,-49.999,0.001> = <-0.5,-0.5,0>, and
0.01*<50.001,50.001,100.001> = <0.5,0.5,1>
Then translate <0,0,0> does nothing at all.

So then you have your first wall so you scale by
<250,260,10>... so
<250,260,10>*<-0.5,-0.5,0>= <-125,-130,0>, and
<250,260,10>*<0.5,0.5,1>=<125,130,10>
which you then translate... so addition
<-125,130,-3.5>+<-125,-130,0> = <-250,0,-3.5>, and
<-125,130,-3.5>+<125,130,10>=<0,260,6.5>
So the first wall is equivalent to 
box{<-250,0,-3.5>,<0,260,6.5>}

So then you have your second wall, which
you scale to size <200,260,15>
so now you have an equivalent
box {<-100,-130,0>,<100,130,15>}
Because BOX is siting on the origin, the center 
of the scaled box is still sitting on the origin,
but the corner you want to rotate around isn't.
So for this example I'll pick a corner... <-100,-130,0>
What you want to do is take that corner and
put it on the origin... so
translate <100,130,0>
then rotate it by some angle say 
rotate y*45
and then put that corner on a corner from the first
wall... say <-250,0,-3.5> so 
translate <-250,0,-3.5>

So to summarize, something like

// first wall
box{<-250,0,-3.5>,<0,260,6.5>}

// second wall
box {<-100,-130,0>,<100,130,15>
   translate <100,130,0>
   rotate y*45
   translate <-250,0,-3.5>
}

But where does that leave the other
corner of the second wall? Before we
rotated it we knew it was at <200,260,0>,
but there's math involved, that could get
complicated. Fortunately, POV has a function
to figure it out for us... vrotate....
so the other corner is at
vrotate(<200,260,0>,y*45)+<-250,0,-3.5>
So, for the third wall you'd translate it to there.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 20:10:00
Message: <web.4a3c279fcfb6d608813d5ca0@news.povray.org>
Tim,
I am grateful for helping me solve a problem that's been bothering me for more
than a year. I got it working, now I can concatenate 2 walls seamlessly at
given angles. A third wall as you mentioned would be a little problematic since
I'm weak on coordinate systems. I guess I must learn vrotate inside out.

I thank you very much again, I also appreciate Chris B and clipka's input.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 20:45:00
Message: <web.4a3c30cacfb6d608813d5ca0@news.povray.org>
Tim,

So then you have your first wall so you scale by
<250,260,10>... so
<250,260,10>*<-0.5,-0.5,0>= <-125,-130,0>, and
<250,260,10>*<0.5,0.5,1>=<125,130,10>
which you then translate... so addition
<-125,130,-3.5>+<-125,-130,0> = <-250,0,-3.5>, and
<-125,130,-3.5>+<125,130,10>=<0,260,6.5>
So the first wall is equivalent to
box{<-250,0,-3.5>,<0,260,6.5>}
--------------------------------------------

Where do you come up with the <-0.5,-0.5,0> for multiplication. Why do you
sometimes add then multiply? Where specifically can I learn more about matrix
manipulations in povray? Sorry for being a burden, Thank you.


Post a reply to this message

From: Tim Attwood
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 22:29:21
Message: <4a3c4981$1@news.povray.org>
> Where do you come up with the <-0.5,-0.5,0> for multiplication. 

<-0.5,-0.5,0> is the coordinate of of the lower-left-forward corner
of the BOX mesh, which is the _box mesh <-49.999,-49.999,0.001>
scaled by 0.01 (and rounded a bit).

> Why do you sometimes add then multiply? 

Addition is equivalent to translation.
So if you have a point at coordinate A and 
translate it by amount B the point is now at
coordinate A+B.

Scaling is equavalent to multiplication.
So if you have a point at coordinate A and 
scale it by amount B, the point is now at 
coordinate A*B. 

You need to be careful with scaling, for
example if you have box{<1,1,1>,<2,2,2>}
and want to triple the size of the box, you
might just scale <3,3,3>, that triples the
size of the box fine, but now it's equivalent
to box{<3,3,3>,<6,6,6>}... it's now moved.
To keep the corner at <1,1,1> you need to
move it to the origin, scale, then put it back. 

>Where specifically can I learn more about matrix 
>manipulations in povray? 

Matrix transforms in POV are equivalent to
multiplying a vector by a 4x4 matrix. The
4th column is assumed to be 0 0 0 1.
Matrix math is covered in linear algebra in
college, I think. The bits to know for POV are...

(1) not all matrix tranforms result in a
valid transform, you could get errors if
you feed it nonsense numbers.

(2) given a matrix (POV docs 2.2.7.1.4) 
matrix <Val00, Val01, Val02,
        Val10, Val11, Val12,
        Val20, Val21, Val22,
        Val30, Val31, Val32>
the result if applied to a point P=<px,py,pz>
is a point Q=<qx,qy,qz> where
qx = Val00 * px + Val10 * py + Val20 * pz + Val30 
qy = Val01 * px + Val11 * py + Val21 * pz + Val31 
qz = Val02 * px + Val12 * py + Val22 * pz + Val32 

(3) a surface of an object is actually a set of points,
so a matrix transform applied to an object moves
all the points (it moves the object). It could scale, 
rotate, and translate, or some form of all three.
Most importantly, it can shear.

(4) Val30, Val31, Val32 (row 4) in a matrix transform
represents a translatation value.

(5) Val00, Val01, Val02  (row 1) in a matrix transform
represents the desired new X direction.

(6) Val10, Val11, Val12  (row 2) in a matrix transform
represents the desired new Y direction.

(7) Val20, Val21, Val22 (row 3) in a matrix transform
represents the desired new Z direction.

(8) The magnitude of the direction "vectors" (5-7) control
scaling.

(9) If you have a matrix transform T1 and a matrix transform
T2, then applying T1 and then T2 to an object is equivalent
to applying a transform T3=T1*T2, with some moderately 
complicated matrix multiplication rules. In other words,
behind the scenes, the list of transforms (translate, rotate, 
scale, matrix) that you feed to an object in POV are reduced 
to a single transform during the parse phase, no matter how
many transforms you use, they're a fixed (per object) cost.

>Sorry for being a burden, Thank you.

No problem.


Post a reply to this message

From: Larry Hudson
Subject: Re: an extraordinary rotation question
Date: 19 Jun 2009 23:42:23
Message: <4a3c5a9f$1@news.povray.org>
mysdn wrote:
> Hello everybody,
>  I'm new at this forum and very interested in ray tracing. Currently, I'm using
> Povray for ray tracing. But I have a huge problem understanding its rotation
...
> Any type of help will be greatly appreciated.
> ibrahim dogan
> Turkey

You have already received far more detailed explanations, so I don't 
know if this is helpful or not.  This is a VERY simple demo of rotations 
and scaling.  And being simple, it might help you visualize how POV-Ray 
handles these things.  The key to remember, ALL rotations and scalings 
are done with respect to the coordinate axes.

This image uses a simple 2-unit box created centered around the origin, 
then rotated/scaled/translated in various ways.

Rotated around z then translated along x (blue)
Translated along x then rotated around z (cyan)
Scaled then translated along y (red)
Translated then scaled along y (magenta)

Then to show the order of the rotations is important...
Rotated around x then around y (yellow)
Rotated around y then around x (orange)

****************************************
#include "colors.inc"

camera {
     location <-2, 2.5, -15>
     look_at 0
}

light_source { <-5, 20, -30> White * 1.2 }

background { SkyBlue }

#declare Cube = box { -1, 1 }

#declare Axes = union {
     cylinder { <-100, 0, 0>, <100, 0, 0>, .05 }
     cylinder { <0, -100, 0>, <0, 100, 0>, .05 }
     cylinder { <0, 0, -100>, <0, 0, 100>, .05 }
     pigment { Gray70 }
     no_shadow
}

object {    //  Rotate followed by translate
     Cube pigment { Blue }
     rotate z * 45
     translate x * 5
}

object {    //  Translate followed by rotate
     Cube pigment { Cyan }
     translate x * 5
     rotate z * 45
}

object {    //  Scale followed by translate
     Cube pigment { Red }
     scale .5
     translate y * 5
}

object {    //  Translate followed by scale
     Cube pigment { Magenta }
     translate y * 5
     scale .5
}

object {    //  Rotate x followed by rotate y
     Cube pigment { Yellow }
     rotate <45, 45, 0>
     translate -x * 6
}

object {    //  Rotate y followed by rotate x
     Cube pigment { Orange }
     rotate y * 45 rotate x * 45
     translate -x * 2
}

plane { y, -5 pigment { Green } }

//  Comment this out for no axes displayed
object { Axes }
*****************************************

Hope this helps.

      -=- Larry -=-


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 20 Jun 2009 05:30:01
Message: <web.4a3cab55cfb6d608813d5ca0@news.povray.org>
Tim, you astounded me by your beautifully detailed answer to my matrix question.
Thanks a million, I think I need a while to let it all sink in.

Larry, thanks for your explanation too, it's as if you read my mind by offering
the sample you did. Cause I was going to ask almost the exact same question
here. Suppose you have 3 kitchen cabinets placed side by side then you rotate
the one in the middle 45 degrees and it loses position again. It should rotate
in place but it ends up some off place, not as off as the wall sample I
offered, but a little off. I guess this is because of the wall's and cabinet's
widths are different.

In the wall sample, we rotated by picking a corner as base rotation point. HOW
would we rotate the cabinet in place? I do this in my app for a year now and it
always moves off a little, this in a commercial application looks very
unprofessional. I would like both Larry's and Tim's input, if possible, because
2 explanations explain more than one.

PS: I am 44 Turkish, married, no kids. my email is jestagu a t y a h o o
if you send me a note I would like to make friends with both of you people. If
you visit izmir-turkey I'd love to show you around, well maybe you heard of
turkish hospitality, I have some of that too.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 20 Jun 2009 05:40:01
Message: <web.4a3cacadcfb6d608813d5ca0@news.povray.org>
<The key to remember, ALL rotations and scalings
<are done with respect to the coordinate axes.

I believe this is the point I'm missing in comprehending pov rotations.
coordinate axes ? To rotate something why should I care about its coordinates.
Shouldn't povray automatically take into account THE coordinates?

Plus first scaling then rotating has direct implications on the new location, as
opposed to only rotating, w/o scaling.


Post a reply to this message

From: Jellby
Subject: Re: an extraordinary rotation question
Date: 20 Jun 2009 07:39:58
Message: <o7uug6-pp.ln1@badulaque.unex.es>
Among other things, mysdn saw fit to write:

> I believe this is the point I'm missing in comprehending pov rotations.
> coordinate axes ? To rotate something why should I care about its
> coordinates. Shouldn't povray automatically take into account THE
> coordinates?
> 
> Plus first scaling then rotating has direct implications on the new
> location, as opposed to only rotating, w/o scaling.

Every rotation has to be done *around* something (some point or axis). The
Earth's rotation takes place around its center (more or less), the Earth's
translation is just rotation around the Sun (more or less), the Moon's
movement around the Earth could be simply described as a rotation around
the Earth.

In POV-Ray, rotations are always around the <0,0,0> point. If an object is
positioned at <0,0,0>, rotating it will just rotate the object, but if the
object is 10 units away, its position will change, because it's like there
was a string between the object and a stick atb <0,0,0>: only the <0,0,0>
point stays fixed.

When you want to rotate an object, think which point(s) of the object should
stay completeley fixed in space (the hinges of a door); well, this point
must be placed at <0,0,0> before rotation or else a translation must be
applied to compensate it.

Similarly with scalings, they are done with respect to <0,0,0>. That means a
1-size sphere centered at <0,0,0> scaled by 2, becomes a 2-size sphere
centered at <0,0,0>; but a 1-size sphere centered 10 units away becomes a
2-size sphere centered 20 units away.

-- 
light_source{9+9*x,1}camera{orthographic look_at(1-y)/4angle 30location
9/4-z*4}light_source{-9*z,1}union{box{.9-z.1+x clipped_by{plane{2+y-4*x
0}}}box{z-y-.1.1+z}box{-.1.1+x}box{.1z-.1}pigment{rgb<.8.2,1>}}//Jellby


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 20 Jun 2009 20:55:00
Message: <web.4a3d831bcfb6d60e4e47a1b0@news.povray.org>
Tim, I have some final questions. Then I think I'll comprehend the whole logic
involving rotations. I feel pretty stupid after all these explanations but I
feel if I get an answer to this list everything will fall into place. By the
way this whole concept is not so easy to grasp without some handholding.
I'm already grateful for all the answers.


in a previous post I asked you where did you come up with the numbers you did.

1- In the example you provided one of the corners is
at <-49.999,-49.999,0.001>, and another at
<50.001,50.001,100.001>.
1- Where are these numbers showing in my sample?

2- When you scale you are relocating the corners around the origin by
multiplication. So
0.01*<-49.999,-49.999,0.001> = <-0.5,-0.5,0>, and
0.01*<50.001,50.001,100.001> = <0.5,0.5,1>

2- Why do you multiply 0.01*<-49.999,-49.999,0.001> = <-0.5,-0.5,0>, and
                       0.01*<50.001,50.001,100.001> = <0.5,0.5,1>


3- So then you have your first wall so you scale by
<250,260,10>*<-0.5,-0.5,0>= <-125,-130,0>, and
<250,260,10>*<0.5,0.5,1>=<125,130,10>

3- Why these 2 multiplications take place?

4- <-0.5,-0.5,0> is the coordinate of of the lower-left-forward corner
of the BOX mesh, which is the _box mesh <-49.999,-49.999,0.001>
scaled by 0.01 (and rounded a bit).

4- Where does it say <-0.5,-0.5,0> is the lower left forward corner of BOX?

5- So the first wall is equivalent to
box{<-250,0,-3.5>,<0,260,6.5>}

5- is <-250,0,-3.5> translate or scale, same question for >,<0,260,6.5>

6- So for this example I'll pick a corner... <-100,-130,0>
6- Which corner is this and how did the number came to be <-100,-130,0>


Post a reply to this message

From: Tim Attwood
Subject: Re: an extraordinary rotation question
Date: 21 Jun 2009 06:53:50
Message: <4a3e113e$1@news.povray.org>
> 1- In the example you provided one of the corners is
> at <-49.999,-49.999,0.001>, and another at
> <50.001,50.001,100.001>.
> 1- Where are these numbers showing in my sample?

The numbers are in the file "box_POV_geom.inc",
as part of the mesh2 definition.

> 2- When you scale you are relocating the corners around the origin by
> multiplication. So
> 0.01*<-49.999,-49.999,0.001> = <-0.5,-0.5,0>, and
> 0.01*<50.001,50.001,100.001> = <0.5,0.5,1>
>
> 2- Why do you multiply 0.01*<-49.999,-49.999,0.001> = <-0.5,-0.5,0>, and
>                       0.01*<50.001,50.001,100.001> = <0.5,0.5,1>

<50.001,50.001,100.001> is the upper-right-rear corner of the
box. Again, this is from "box_POV_geom.inc", the multiplication
by 0.01 comes from the scale in line 20 of "rotation.pov"

#declare BOX = object { box_  scale <0.01,0.01,0.01> translate <0, 0, 0> }

Note that translate <0,0,0> doesn't do anything and could be omited.
So we have here the coordinates of two corners of the mesh2 "box_",
which is redeclared as "BOX" and scaled.

> 3- So then you have your first wall so you scale by
> <250,260,10>*<-0.5,-0.5,0>= <-125,-130,0>, and
> <250,260,10>*<0.5,0.5,1>=<125,130,10>
>
> 3- Why these 2 multiplications take place?

In line 25 of "rotation.pov" you scale "BOX".
So these are the coordinates of the object statement started on
line 24, as of the scaling. It's translated later in line 27.

> 4- <-0.5,-0.5,0> is the coordinate of of the lower-left-forward corner
> of the BOX mesh, which is the _box mesh <-49.999,-49.999,0.001>
> scaled by 0.01 (and rounded a bit).
>
> 4- Where does it say <-0.5,-0.5,0> is the lower left forward corner of 
> BOX?

POV by default uses a left handed coordinate system... so plus Y is
up, plus X is right, plus Z is away. It's called left handed because
you can hold your left hand with the thumb up (Y), the pointer finger
forward (Z), and the middle finger right (X) to visualize the XYZ axis.
You can also picture the direction of rotations that way. If you make
the XYZ axis with your left hand, then if you trace from the palm
of the left hand over the middle finger, that's positive X, and
continue tracing over the middle finger, that's positive Z, and then
tward you around the thumb, that's positive Y.

So it's that corner because it was the vector with the minimum values.
Note that in this case the corner happened to be equal to the result
of the min_extent function, but it's not required to be equal.

> 5- So the first wall is equivalent to
> box{<-250,0,-3.5>,<0,260,6.5>}
>
> 5- is <-250,0,-3.5> translate or scale, same question for >,<0,260,6.5>
Yeah, box{<-250,0,-3.5>,<0,260,6.5>} should be equivalent to
the first wall, as per line 24-28 of "rotation.pov", that's what
is going on. It's just a mental stand-in for the mesh, which in
the sample is actually a box, but if the mesh is somewhat box-like
(say a cabinet) it's still a valid picture of where it is.

> 6- So for this example I'll pick a corner... <-100,-130,0>
> 6- Which corner is this and how did the number came to be <-100,-130,0>

It's the front-left-bottom corner of the second wall,
declared as "ek_duvar12" in line 33-41 of "rotation.pov".
Which is  <-0.5,-0.5,0>*<200,260,15>, the
corner of "BOX" scaled as per line 36.


Post a reply to this message

From: clipka
Subject: Re: an extraordinary rotation question
Date: 21 Jun 2009 09:20:00
Message: <web.4a3e32f1cfb6d60c9dd53ff0@news.povray.org>
"Tim Attwood" <tim### [at] anti-spamcomcastnet> wrote:
> POV by default uses a left handed coordinate system... so plus Y is
> up, plus X is right, plus Z is away. It's called left handed because
> you can hold your left hand with the thumb up (Y), the pointer finger
> forward (Z), and the middle finger right (X) to visualize the XYZ axis.

As a side note, I think this is an extremely ugly way of defining a "left
handed" coordinate system, because it appears somewhat arbitrary: If your Y was
away and Z was up, would it still be a left-handed system? After all, you could
point the fingers of your left hand in exactly the same way, just "numbering"
them differently.

The answer is "no", but the description gives no hint why that would be a
right-handed coordinate system instead.

It gets clearer when one introduces a strictly systematic "naming" for the
fingers: Starting from the thumb, call your fingers "X", "Y" and "Z". So point
your thumb to the right (X), your index finger up (Y), and your middle finger
away (Z).


> You can also picture the direction of rotations that way. If you make
> the XYZ axis with your left hand, then if you trace from the palm
> of the left hand over the middle finger, that's positive X, and
> continue tracing over the middle finger, that's positive Z, and then
> tward you around the thumb, that's positive Y.

This, too, appears to be quite arbitrary. There's another, IMHO much more
intuitive way to picture rotation in a left-handed coordinate system:

Make a "thumbs up" sign with your left hand. Hold it so that your thumb points
into the direction you're rotating about. Rotating by a positive value now
corresponds to moving along your curved fingers towards the fingertips.


Same gymnastics work accordingly for a right-handed coordinate system, of
course. Just use your right hand then.


Unfortunately, the POV-Ray documentation is somewhat inconsistent about how to
visualize handedness; while "2.2.1.1  Understanding POV-Ray's Coordinate
System" uses the imagery I just described, "3.3.1.1.7  Handedness" uses the
more contrived variant for depicting the coordinate axes with your hand (but
just refers to 2.2.1.1 for rotation).


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 21 Jun 2009 10:25:00
Message: <web.4a3e4231cfb6d60e4e47a1b0@news.povray.org>
Thanks to all contributors in this thread.

Larry, clipka, Jellby, Chris B and especially Tim AttWood.
This was an exercise for professional reasons not hobby,so it's pretty important
for me. I appreciate everything you guys have done. I will take about a week to
digest all your posts and if you don't hear from me again in about a week you
can assume I got it, thanks to you helpful people. I would share my knowledge
in a split second if somebody asked for it too.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 22 Jun 2009 07:55:00
Message: <web.4a3f70a0cfb6d60e4e47a1b0@news.povray.org>
Hi, thank you guys, I can now rotate a wall attached to another.
But I realize my problems are much bigger than that or so they seem.

I can't do rotation when using Unions, I posed a few more questions in the zip
file which can be dowloaded from

http://ompf.org/forum/download/file.php?id=249

Note: you can paste this into your browsers addres bar and press Enter, download
dialog will pop up.

My God, It's as if I sensed rotations would send me berserk from last year.
On this subject I'm free falling. At the mercy of people like you guys. Thanks.


Post a reply to this message

From: Tim Attwood
Subject: Re: an extraordinary rotation question
Date: 22 Jun 2009 20:28:13
Message: <4a40219d$1@news.povray.org>
> Hi, thank you guys, I can now rotate a wall attached to another.
> But I realize my problems are much bigger than that or so they seem.
>
> I can't do rotation when using Unions, I posed a few more questions in the 
> zip
> file which can be dowloaded from
>
> http://ompf.org/forum/download/file.php?id=249
>
> Note: you can paste this into your browsers addres bar and press Enter, 
> download
> dialog will pop up.
>
> My God, It's as if I sensed rotations would send me berserk from last 
> year.
> On this subject I'm free falling. At the mercy of people like you guys. 
> Thanks.

Here's an example of how I would do it with your meshes.
Maybe that will help you more.

http://news.povray.org/povray.binaries.scene-files/attachment/%3C4a40205e%40news.povray.org%3E/us-ascii


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 04:45:00
Message: <web.4a409418cfb6d60e4e47a1b0@news.povray.org>
Tim,
I can't tell you enough how much I appreciate your input. Latest example was
brilliant it gave me some ideas on how to proceed, but some issues still
remain.
You must be an angel for having the patience to bear with me. This thread will
be a godsend for those who will follow this trail.

1- // the angled cabinet
object {
   CABINET
   translate <0,0,60> // place front-left-bottom corner on origin
1- Why do we translate to <0,0,60>, what if I want to rotate around right front
corner then what would this value be ? I think this point needs elaboration.
Did you multiply <-0.5,-0.5,0>*<x,x,x>?

2- Declaring a Cabinet Union, then just copying and placing them on the scene is
brilliant. That's the route I want to go for each similar object. But each
cabinet may have different texture, handle, door model applied to it.
So in
// the left cabinet
object {
   CABINET
   translate <0,0,0>
   rotate <0,0,0>
   translate <0,10,0> // raise bottom of cabinet to kick height
}
How should I proceed to reflect these different characteristics in the object?

I have a feeling these won't be my last questions.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 05:25:00
Message: <web.4a409e00cfb6d60e4e47a1b0@news.povray.org>
Tim,
on second thought, I don't think I can use
// cabinet
#declare CABINET = union {
   // case
   object{
      box_ //
because as I said each cabinet may have different characteristics, even no
characteristics such as no door, no handle, then our "declare CABINET" would be
useless, cause it defines a solid , fixed model. We need an adjustable model
definition, with following specifications adjusted diffrently for each cabinet.

location
scale
case texture
door texture
handle texture
door model
handle model

all these may be diffrent for each cabinet, I think we should construct a
separate Union for each cabinet, What do you think? My previous post questions
still valid. Thank you.


Post a reply to this message

From: Tim Attwood
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 07:46:23
Message: <4a40c08f$1@news.povray.org>
> 1- // the angled cabinet
> object {
>   CABINET
>   translate <0,0,60> // place front-left-bottom corner on origin
> 1- Why do we translate to <0,0,60>, what if I want to rotate around right 
> front
> corner then what would this value be ? I think this point needs 
> elaboration.
> Did you multiply <-0.5,-0.5,0>*<x,x,x>?

The meshes are 100 wide by 100 tall by 100 deep.
So after aligning everything at that size, it's all scaled
by scale <0.5,0.75,0.6>... so that's
<100,100,-100>*<0.5,0.75,0.6> = <50,75,-60>
which is the coordinates of the top-right-forward
corner, but it's also the dimensions, since the opposite
corner is on <0,0,0>.

The reason it's translated by <0,0,60> is to put the
left-front corner on the origin for rotatation around
the Y axis.

If you wanted to rotate arount the front-right corner,
then you'd translate by <-50,0,60>, putting the
front-right corner on the origin before rotating.
Then you place it with another translation.

> 2- Declaring a Cabinet Union, then just copying and placing them on the 
> scene is
> brilliant. That's the route I want to go for each similar object. But each
> cabinet may have different texture, handle, door model applied to it.
> So in
> // the left cabinet
> object {
>   CABINET
>   translate <0,0,0>
>   rotate <0,0,0>
>   translate <0,10,0> // raise bottom of cabinet to kick height
> }
> How should I proceed to reflect these different characteristics in the 
> object?

Yeah, you probably will end up with a union for every unique cabinet,
that's normal. You'll need to number them or something. You might
end up with different shelving options for the cases too? It doesn't
matter much, with the doors closed you can't see the inside.
If you plan to open any of the doors, then you should keep track
of the hinge location, that way you can move the cabinet so that
the Y axis lines up along the hinges, rotate open the door (in the union)
and then place it back.

The more complicated your meshes get the harder it'll be to determine
where the corners of your mesh object are. It's worth the small amount
of time it takes to try to line up a corner with the origin in your
modeling package. That way you can just import the meshes,
and then place them into a union without having to manually
re-align each part.


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 08:50:44
Message: <4a40cfa4$1@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a409e00cfb6d60e4e47a1b0@news.povray.org...
> Tim,
> I don't think I can use
> #declare CABINET = union { ...
> because as I said each cabinet may have different characteristics, even no
> characteristics such as no door, no handle, then our "declare CABINET" 
> would be
> useless, cause it defines a solid , fixed model. We need an adjustable 
> model
> definition, with following specifications adjusted diffrently for each 
> cabinet.
>
> location
> scale
> case texture
> door texture
> handle texture
> door model
> handle model
>
> all these may be diffrent for each cabinet, I think we should construct a
> separate Union for each cabinet, What do you think?
>

One approach could be to use a macro. The example below adds 3 different 
cabinets, generated based on variable settings. Each variable has a default 
value that is set at the start of the macro.  The first macro call generates 
the default cabinet. The second uses a Cyan colored door with the door half 
open. The third has no door.

You mentioned a 2D application at the start of this thread. This would 
enable you to use a 2D graphics application to define a layout for the 
cabinets. Your application could pick up the positions, sizes and 
orientations from a 2D vector image and use this POV-Ray macro (which you 
can make as sophisticated as you like) to generate cabinets with the 
required specifications. I did something similar a few years back using SVG 
graphics to define the layout of a some houses 
(http://www.geocities.com/povstairs/povhouse/).

camera {location <-1, 1.2, -1> look_at <0.6,0.3,0>}
light_source {<2,20,-4> color rgb 2}

#macro Cabinet ()

  // Default Cabinet Variables
  #ifndef (Height) #declare Height = 0.9; #end
  #ifndef (Width)  #declare Width  = 0.6; #end
  #ifndef (Depth)  #declare Depth  = 0.6; #end
  #ifndef (Thickness)  #declare Thickness  = 0.012; #end
  // Default Door Variables
  #ifndef (Door_Thickness) #declare Door_Thickness  = 0.02; #end
  #ifndef (Door_OpenAngle) #declare Door_OpenAngle  = 0;    #end
  #ifndef (HasDoor)        #declare HasDoor  = true;        #end

  // Default Textures
  #ifndef (Cabinet_Texture)
    #declare Cabinet_Texture = texture {pigment {rgb 1}}
  #end
  #ifndef (Door_Texture)
    #declare Door_Texture = texture {pigment {rgb <1,1,0>}}
  #end

  union {
    // Cabinet
    difference {
      box {<0,0,0><Width,Height,Depth>}
      box {<Thickness,0.15,-0.001>
           <Width,Height,Depth>-Thickness
      }
      texture {Cabinet_Texture}
    }
    // Door
    #if (HasDoor)
      box {<0,0,0><Width,Height,-Door_Thickness>
        texture {Door_Texture}
        rotate y*Door_OpenAngle
      }
    #end
  }

#end

// Add 3 cabinets to the scene by calling the macro

// Default Cabinet
object {Cabinet()}

// Custom Cabinet
#declare Width = 0.8;
#declare Door_Texture = texture {pigment {rgb <0,1,1>}}
#declare Door_OpenAngle  = 45;
object {Cabinet() rotate y*45 translate 0.62*x}

// Doorless Cabinet
#declare Width = 0.3;
#declare HasDoor  = false;
object {Cabinet() translate -0.32*x}


Regards,
Chris B.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 10:14:17
Message: <4a40e339$1@news.povray.org>
mysdn wrote:

> on second thought, I don't think I can use
> // cabinet
> #declare CABINET = union {
>    // case
>    object{
>       box_ //
> because as I said each cabinet may have different characteristics

As Chris already said you can use a macro for this. In addition
to his suggestion, note that macros can have parameters and do not
need to use global variables. From a software engineering view that
would be preferred because it avoids conflicts with other macros
or variable names you wish to use for something else (the name
of a parameter is *local* to a macro, as is a variable which is
declared using #local instead of #declare within the macro):

   #macro Cabinet(Width,Height,Depth,Thickness,
                  Door_Thickness,Door_OpenAngle, HasDoor
                  Cabinet_Texture, Door_Texture)
   union
   {
     // Cabinet
     difference
     {
       box {<0,0,0><Width,Height,Depth>}
       ...
     }
   }

   #end

You would then need to call it like

   Cabinet(0.6,0.9,0.6,0.012,0.02,0,true)


To not always have to specify all parameters, you
can then specialize this with mechanisms like

   #macro CabinetModelA(Width,Height,Depth,Door_OpenAngle)
     #local T_DOOR    = texture {...}
     #local T_CABINET = texture {...}
     Cabinet(Width,Height,Depth,0.012,0.02,Door_OpenAngle,true,
             T_DOOR,T_CABINET)
   #end

   #macro CabinetModelB(Width,Height,Depth)
     #local T_DOOR    = texture {...}
     #local T_CABINET = texture {...}
     Cabinet(Width,Height,Depth,0.012,0.02,0,false,
             T_DOOR,T_CABINET)
   #end

   CabinetModelA(1,1.5,0.4,30)

   CabinetModelB(0.5,0.7,0.5)


Finally, you might wish to have a look at some existing
scene source code before losing yourself in the details of
your own. E.g., have a look at IRTC images such as those under
http://www.irtc.org/irtc/irtc?_n&pg=ViewSummary&id=StillImages_September-October2006
Many images provide a "source" link (and most of those are
done with POV-Ray). This helps prevent reinventing the wheel.
Reusing an object is useful, but not exactly "brilliant" ;)


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 11:01:46
Message: <4a40ee5a$1@news.povray.org>
"Christian Froeschlin" <chr### [at] chrfrde> wrote in message 
news:4a40e339$1@news.povray.org...
> ...  note that macros can have parameters and do not
> need to use global variables. From a software engineering view that
> would be preferred because it avoids conflicts with other macros
> or variable names you wish to use for something else

I ceratinly agree that in many programming languages, other approaches would 
be preferable, but POV-Ray is a bit limited in this respect and the use of 
global variables to control macros that require large numbers of controls is 
the best approach I've been able to come up with in POV-Ray from a software 
engineering perspective.

The main advantage with using variables in this way is that you can specify 
just the variables you need, whereas to accommodate all desired permutations 
using the 'MacroA, MacroB etc' technique could require thousands of wrapper 
macros.

In this instance, to parameterise drawers, doors, door-handles, the cabinet 
itself, shelves, kickboards and worktops, each with an average of 6 
parameters for dimensions, colors, openness, handedness etc, you could 
pretty quickly get up to 40 or 50 settings, which, IMO, becomes difficult 
and messy to manage with parameters. OTOH, in this particular case, if the 
macro call is always to be written by an external application then I admit 
that this could still be viable.

With the object collection it was also discovered that the use of local 
variables didn't guarantee you won't get naming collisions, because certain 
identifiers always have a global context, whereas adhering to simple naming 
standards, for both local and global variables, seem to readily avoid all 
those sorts of problems.

Regards,
Chris B.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 11:55:01
Message: <web.4a40f8fccfb6d60e4e47a1b0@news.povray.org>
Thanks for all comments again, everything said will be taken into consideration,
I don't know when I will have my aha moment, specially on the subject of
rotations, because that subject pushes my limits.
In the zip file I attached you'll find a complete kitchen ready to render in
povray. Then you'll see exactly what I'm trying to do and what would be the
best way to go about it. This sample kitchen was produced by a C# app that
writes SDL files for POV.
As you can see in the sample kitchen I already have a working algorithm in my C#
app for producing solid, working .pov files.

The first reason I came to this forum was to ask about rotations, now it's more
like, am I doing all this the best possible way? In a design not all objects
are cabinets, it may be sinks, lamps, couches these are mesh objects though.
But now we talk about cabinets.

I produce all my cabinets from box_geom which is 100x100x100 in xyz size
representing 100 cm, cause then I divide it by 0.01, so that I can multiply it
by eg. 60 representing 60 cm, this for example can be a cabinets width or
whatever, in short this way of dimensioning lets me work in mm.

Any comments on how to approach producing this kitchen from SDLs, possibly you
would suggest a Union for each cabinet?

http://www.optimadekor.com/yesdownload/my_kitchen.zip


PS: in the zip the jpeg "2D design" tells the same story in 2D.


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 13:28:01
Message: <4a4110a1@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a40f8fccfb6d60e4e47a1b0@news.povray.org...
>
> The first reason I came to this forum was to ask about rotations, now it's 
> more
> like, am I doing all this the best possible way? In a design not all 
> objects
> are cabinets, it may be sinks, lamps, couches these are mesh objects 
> though.
> But now we talk about cabinets.
>

There's not necessarily a universally 'best possible' way. If you've got the 
objects you need or you've got a way that you're comfortable with producing 
them (e.g. a modelling tool) in the various configurations you need, then 
there's no compelling need to change. The technique you've got may well be 
the best way for you.

Currently you seem to be using meshes througout. This has the advantage of 
being closer to other formats in case you want to interface to other 
renderers or any modeller or 3D display applications in the future. OTOH 
Using POV-Ray primitives, such as boxes, spheres etc could make the POV file 
easier to read and more compact, but that depends whether you need anyone to 
read it. If you are simply using POV-Ray to render from your application, 
then those considerations may not be important.

> I produce all my cabinets from box_geom which is 100x100x100 in xyz size
> representing 100 cm, cause then I divide it by 0.01, so that I can 
> multiply it
> by eg. 60 representing 60 cm, this for example can be a cabinets width or
> whatever, in short this way of dimensioning lets me work in mm.
>
> Any comments on how to approach producing this kitchen from SDLs, possibly 
> you
> would suggest a Union for each cabinet?
>

You can use a union to assemble the components of the cabinet into a single 
unit if you wish. One reason you may like to do this would be to be able to 
position and orient the cabinet as a single unit, rather than having to work 
out the tranformations required for each separate part of the cabinet. This 
is only if it makes it easier for you to develop though. If you are more 
comfortable keeping the components separate then I don't see any particular 
need to join them together using a CSG union.

Regards,
Chris B.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 18:30:01
Message: <web.4a415687cfb6d60e4e47a1b0@news.povray.org>
"Tim Attwood" <tim### [at] anti-spamcomcastnet> wrote:

< The more complicated your meshes get the harder it'll be to determine
< where the corners of your mesh object are. It's worth the small amount
< of time it takes to try to line up a corner with the origin in your
< modeling package. That way you can just import the meshes,
< and then place them into a union without having to manually
< re-align each part.

I use 3ds max and always center my models on XYZ 0,0,0 respectively on absolute
world coordinates of max. I hope that's the right thing to do.

the box_geom you saw in samples was also exported from max with same settings


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 23 Jun 2009 19:30:00
Message: <web.4a4163bbcfb6d60e4e47a1b0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:

> You mentioned a 2D application at the start of this thread. This would

Yes, a 2D app is going to write the whole SDL file, so it needs to be automated.
and I love this macro idea, if I can get it to actualy work.

The macro idea seems like the key but it must be parameterized for different
types cabinets, I suppose there would be upto 100 macros for cabinets. Other
objects in my scene don't need macros defined for them cause they are mesh
objects. Mostly, this is a cabinet application and it will be cabinets causing
the biggest headaches. Yes Froeschlin suggested  a parameterized macro but he
left it empty inside, could you guys fill in some more blanks in that macro?
I need some variables set inside the macro, some variables set at object
declaration, meaning when placed in the scene.

macro should use the box_POV_geom.inc I exported from Max, scaled to
<0.01,0.01,0.01> so that we can multiply it by eg. 50 (that will be 50 cm)
sample cabinet's width 50, height 75, depth 60 cm
for textures I use jpegs

the case of cabinet should be constructed by 5 pieces of box_POV_geom.inc, not
CSG. Because I want to texture side panels and top , bottom differently.
the door also constructed as 6th piece from box_POV_geom.inc
the handle is a mesh I have, you can use box_POV_geom.inc, just to show

Variables inside macro, all values passed to the macro at invoke time:

Scale xyz
rotate xyz (maybe this can be left outside the parameter list and set from call)
case_texture
door_texture
shelf_texture
handle_texture
shelfCount
hasDoor
hasCountertop
hasToe
hasTopMolding
hasBottomMolding
hasHandle
handle_right_left (or hinge)
handle_Pos   (handle may be anywhere on cabinet)

Can you comment the code some, especially the variables, declarations?
I guess I can put the macro in a text file, place it in POV folder and call it
from the SDL, right?

It will certainly clarify a lot. I thank you all from the bottom of my heart.
I don't want you people to do my work for me, I'm trying to learn, cause with
hundreds of macros I need, no one can do it for me? just teach me if you will.
It seems like I only need one fully working macro. Then I 'll take it form there
like a thunder.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 03:50:00
Message: <web.4a41d72acfb6d60e4e47a1b0@news.povray.org>
Hi,
I got most of the macro working, only a few problems, sorry for sounding really
stupid. My previous request for a macro sample is rendered obsolete by this
post. Cause I got a macro (Chris B's sample) working even though still missing
a lot of functionality.

1- I can't pass the texture names to macro as a parameter
2- I need another Union inside Cabinet Union for door, the door and the handle
should be another Union inside Cabinet Union. So when we open the door the
handle moves along. Right?
3- the handle may be on the right or left of the door , how do we handle that?
   thus the hinge place changes, thus the door opens to a different side....

that's it for now I'm working on it, these 3 are all I'm stuck on right now.

PS: in the future I'll need a challenging macro for angled cabinets. Remember
the angled wall, well what if it needs a cabinet placed in its angled corner.
That cabinet should be angled accordingly in 2 pieces, single door. To
understand what I'm saying , draw a straight line 50 cm, at right side draw
another line 40 cm at 40 degrees rotated towards yourself, now make that into a
cabinet on paper.

Thanks a million


------------ the code I got working--------improvised Chris B's code
// How does it look?

//#include "Cabinet.inc"

camera {location <-1, 1.2, -1> look_at <0.6,0.3,0>}
light_source {<2,20,-4> color rgb 2}


#macro Cabinet (Width,Height,Depth,HasDoor,Door_OpenAngle)


  #ifndef (Thickness)  #declare Thickness  = 0.012; #end
  // Default Door Variables
  #ifndef (Door_OpenAngle) #declare Door_OpenAngle  = 0;    #end
  #ifndef (HasDoor)        #declare HasDoor  = true;        #end

  // Default Textures
  #ifndef (Cabinet_Texture)
    #declare Cabinet_Texture = pigment {image_map {jpeg "yo_toprak"}scale 1 }
  #end
  #ifndef (Door_Texture)
    #declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
  #end

  union {
    // Cabinet
    difference {
      box {<0,0,0><Width,Height,Depth>}
      box {<Thickness,0.15,-0.001>
           <Width,Height,Depth>-Thickness
      }
      texture {Cabinet_Texture}
    }
    // Door
    #if (HasDoor)
      box {<0,0,0><Width,Height,-0.02>
        texture {Door_Texture}
        rotate y*Door_OpenAngle
      }
    #end
  }

#end


// Add 3 cabinets to the scene by calling the macro

// Default Cabinet
#declare Cabinet_Texture = pigment {image_map {jpeg "yldz_yesiltarra"}scale 1 }
#declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
object {Cabinet(0.5,0.75,0.6,true,0) rotate y*0 translate 0.0*x translate 0.10*y
translate 0.15*z}



// Custom Cabinet
#declare Cabinet_Texture = pigment {image_map {jpeg "yo_toprak"}scale 1 }
#declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
object {Cabinet(0.5,0.75,0.6,true,45) rotate y*45 translate 0.62*x translate
0.10*y translate 0.15*z}

// Doorless Cabinet
#declare Cabinet_Texture = pigment {image_map {jpeg "yo_toprak"}scale 1 }
#declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
object {Cabinet(0.35,0.75,0.6,true,0) rotate y*0 translate -0.38*x translate
0.10*y translate 0.15*z}


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 04:54:26
Message: <4a41e9c2$1@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a41d72acfb6d60e4e47a1b0@news.povray.org...
> Hi,
> I got most of the macro working, only a few problems, ..
>
> 1- I can't pass the texture names to macro as a parameter

Yes you can, but it's usually best to #declare a texture and use it's name 
as a parameter:
#declare MyTexture = texture {pigment {rgb <1,1,0>}}
MyMacro(0,1,MyTexture,2,3)


> 2- I need another Union inside Cabinet Union for door, the door and the 
> handle
> should be another Union inside Cabinet Union. So when we open the door the
> handle moves along. Right?

You can nest unions within one another. Yes it's easiest to union the handle 
to the door before you move the back left or right edge of that union to the 
origin to rotate (open) it.


> 3- the handle may be on the right or left of the door , how do we handle 
> that?
>   thus the hinge place changes, thus the door opens to a different 
> side....

I would recommend having a 'HingeSide' setting of '1' for right, or '-1' for 
left. Then, for the door handle you can do something like
translate <-HingeSide*0.4*Width,HandleHeight,DoorThickness>
// Note the '-' sign to bring the handle to the opposite side to the hinge.

then with the union of the door and handle you'd have something like:
translate <HingeSide*Width,0,0>
rotate y*Door_OpenAngle
translate <-HingeSide*Width,0,0>


Regards,
Chris B.


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 05:23:43
Message: <4a41f09f$1@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a415687cfb6d60e4e47a1b0@news.povray.org...
> "Tim Attwood" <tim### [at] anti-spamcomcastnet> wrote:
>
> < The more complicated your meshes get the harder it'll be to determine
> < where the corners of your mesh object are. It's worth the small amount
> < of time it takes to try to line up a corner with the origin in your
> < modeling package. That way you can just import the meshes,
> < and then place them into a union without having to manually
> < re-align each part.
>
> I use 3ds max and always center my models on XYZ 0,0,0 respectively on 
> absolute
> world coordinates of max. I hope that's the right thing to do.
>

There's no absolute right or wrong, but being too rigorous about centreing 
things can be problematic. If you centre the cabinet base and you 
independently centre the segment of worksurface to go on top of it then, 
because the two are a different depth, you have a slightly more complicated 
calculation to do to align the two (ie it takes longer to code, test and 
fix).

Other examples: Centreing a model of a door handle makes it slightly more 
difficult to align it to the front of the door than if you model it with the 
point at which it connects to the door at the origin. Vertically centreing 3 
different sinks doesn't seem to be as logical as modelling them so that the 
height at which they connect with the worksurface is consistent across all 
your sink models. It might be easier to position your cabinets and slot them 
together if the back left corner of a cabinet was always in a consistent 
position.

It may be worth taking account of such assembly requirements when 
considering what to use as your modelling datum for each element of the 
construction.

Regards,
Chris B.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 10:00:01
Message: <web.4a423009cfb6d60e4e47a1b0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:

> It might be easier to position your cabinets and slot them
> together if the back left corner of a cabinet was always in a consistent
> position.

What do you mean by a consistent position?

Wouldn't this position be <0,0,0> for each object then translated and rotated to
proper place within the Unions in the macro I'm trying to create.
Thank you for your input, it's making a big big difference with every post.

How can I incorporate a handle.inc in below Union?

#macro Cabinet
(Width,Height,Depth,HasDoor,Door_OpenAngle,Cabinet_Texture,Door_Texture)


  union {
    // Cabinet

    box {<0,0,0><Width,Height,Depth> pigment {image_map {jpeg
Cabinet_Texture}scale 0.5 } finish {phong 1 ambient 0.6 reflection 0}}



    // Door
    #if (HasDoor)
      box {<0,0,0><Width -1 ,Height -1,2> pigment {image_map {jpeg
Door_Texture}scale 0.5 }// finish {phong 1 ambient 0.6 reflection 0}}

        //texture {Door_Texture}
        rotate y*Door_OpenAngle
        translate z*60
      }
    #end

     //Handle
     /*
    #if (HasHandle)//INSTEAD OF box A HANDLE.INC (mesh) NEEDS TO BE DEFINED HERE
      box {<0,0,0><Width -1 ,Height -1,2> pigment {image_map {jpeg
Door_Texture}scale 1 } //finish {phong 1 ambient 0.6 reflection 0}}

        //texture {Door_Texture}
        rotate y*Door_OpenAngle
        translate z*60
      }
    #end
       */





  }

#end

PS: I'm thinking about opening a thread on macros, this has become an issue of
creating hundreds of macros for me.


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 11:32:21
Message: <4a424705@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a423009cfb6d60e4e47a1b0@news.povray.org...
> "Chris B" <nom### [at] nomailcom> wrote:
>
>> It might be easier to position your cabinets and slot them
>> together if the back left corner of a cabinet was always in a consistent
>> position.
>
> What do you mean by a consistent position?
>
> Wouldn't this position be <0,0,0> for each object then translated and 
> rotated to
> proper place within the Unions in the macro I'm trying to create.
> Thank you for your input, it's making a big big difference with every 
> post.
>

Yes, but in the modeller you need to decide which bit of a model is 
positioned at <0,0,0>.
If you centre two differently shaped door handle models so that their 
geometric centres are at <0,0,0>, then you have to perform different 
translations to fit each of them to a door. It's less work for you to model 
all handles so that the point at which they are attached to the door is at 
<0,0,0>, then all handles will be translated by the same amount to attach 
them to the doors. The same is true of taps and a similar logic can be 
applied with other fittings and fixtures to work out the optimum point on 
the model to position at <0,0,0>.


> How can I incorporate a handle.inc in below Union?

One way would be to add the name of the style of the handle into the file 
name, then pass the style name into the macro.
For example, if you pass in a style name of "roundgold" and the include file 
'handle_roundgold' contains the declaration for:

#declare Handle = mesh2 { ....}

Then you could have something like:

#macro Cabinet
(Width,Height,Depth,HasDoor,Door_OpenAngle,Cabinet_Texture,Door_Texture,HandleStyle)

#include concat("handle_",HandleStyle,".inc")

union {
    // Cabinet
    ... snip ...
    // Door
   #if (HasDoor)
       ... snip ...

      //Handle
      #if (HasHandle)
           object {Handle texture {...}}
      #end
   #end
}

Note that by nesting the '#if' for the handle inside the '#if' for the door 
you avoid having a handle with no door.


> PS: I'm thinking about opening a thread on macros,

That's probably a good idea, this thread has strayed a bit off the original 
topic.

> this has become an issue of
> creating hundreds of macros for me.

Personally I'd tend to try to avoid having hundreds of macros if it were me, 
but that's just down to programming style.

Regards,
Chris B.


Post a reply to this message

From: Tim Attwood
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 18:17:16
Message: <4a42a5ec$1@news.povray.org>
> I got most of the macro working, only a few problems, sorry for sounding 
> really
> stupid. My previous request for a macro sample is rendered obsolete by 
> this
> post. Cause I got a macro (Chris B's sample) working even though still 
> missing
> a lot of functionality.
>
> 1- I can't pass the texture names to macro as a parameter
> 2- I need another Union inside Cabinet Union for door, the door and the 
> handle
> should be another Union inside Cabinet Union. So when we open the door the
> handle moves along. Right?
> 3- the handle may be on the right or left of the door , how do we handle 
> that?
>   thus the hinge place changes, thus the door opens to a different 
> side....
>
> that's it for now I'm working on it, these 3 are all I'm stuck on right 
> now.
>
> PS: in the future I'll need a challenging macro for angled cabinets. 
> Remember
> the angled wall, well what if it needs a cabinet placed in its angled 
> corner.
> That cabinet should be angled accordingly in 2 pieces, single door. To
> understand what I'm saying , draw a straight line 50 cm, at right side 
> draw
> another line 40 cm at 40 degrees rotated towards yourself, now make that 
> into a
> cabinet on paper.
>
> Thanks a million
>
>
> ------------ the code I got working--------improvised Chris B's code
> // How does it look?

Not bad =)

Here's a rewrite demonstrating passing values to a macro by global
variables. There's nothing wrong with using parameters and ifndef,
but if you use one of the ifndef values, then it will persist to the next
macro call, which is can cause odd behavior.

camera {location <-1, 1.2, -1> look_at <0.6,0.3,0>}
light_source {<2,20,-4> color rgb 2}

// macro to initialize default values
#macro NewCabinet()
   #declare Thickness = 0.012;
   #declare Door_OpenAngle  = 0;
   #declare HasDoor  = true;
   #declare Cabinet_Texture = pigment {image_map {jpeg "yo_toprak"}}
   #declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}}
   #declare Width = 0.5;
   #declare Height = 0.75;
   #declare Depth = 0.6;
   #declare HasHandle = false;
   #declare Handle_Object = sphere {<0,0,-0.05>,0.05};
   #declare Handle_Texture = pigment {rgb <1,1,1>};
   #declare Handle_At = <0.15,0.6,-0.02>;
#end

// build a Cabinet
#macro Cabinet()
  union {
    // case
    difference {
      box {<0,0,0><Width,Height,Depth>}
      box {<Thickness,0.15,-0.001>
           <Width,Height,Depth>-Thickness
      }
      texture {Cabinet_Texture}
    }
    // door
    #if (HasDoor)
      box {<0,0,0><Width,Height,-0.02>
        texture {Door_Texture}
        rotate y*Door_OpenAngle
      }
    #end
    // handle
    #if (HasHandle)
      object {
         Handle_Object
         texture {Handle_Texture}
         translate Handle_At
         rotate y*Door_OpenAngle
      }
    #end
  }
#end

// Add 3 cabinets to the scene by calling the macro
// Default Cabinet
NewCabinet()
#declare Cabinet_Texture = pigment {image_map {jpeg "yldz_yesiltarra"}scale 
1 }
#declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
object {Cabinet() rotate y*0 translate 0.0*x translate 0.10*y
translate 0.15*z}

// Custom Cabinet
NewCabinet()
#declare Cabinet_Texture = pigment {image_map {jpeg "yo_toprak"}scale 1 }
#declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
#declare Door_OpenAngle = 45;
object {Cabinet() rotate y*45 translate 0.62*x translate
0.10*y translate 0.15*z}

// Doorless Cabinet
NewCabinet()
#declare Cabinet_Texture = pigment {image_map {jpeg "yo_toprak"}scale 1 }
#declare Door_Texture = pigment {image_map {jpeg "A366_abanoz"}scale 1 }
#declare Width = 0.35;
#declare HasDoor = false;
object {Cabinet() rotate y*0 translate -0.38*x translate
0.10*y translate 0.15*z}


Post a reply to this message

From: Christian Froeschlin
Subject: Re: an extraordinary rotation question
Date: 24 Jun 2009 18:42:38
Message: <4a42abde$1@news.povray.org>
Chris B wrote:

> The main advantage with using variables in this way is that you can 
> specify just the variables you need

Yes, I reckoned you used that mechanism for more convenient
default values. However, it's not quite true you only need to
specify the variables you need: you also need to reset those
which have been modified for some previous invocation of
the macro, and you may not always be aware of those.

That problem could be prevented by having two macros for
each object, the first one just resetting the defaults:

#macro Begin_Cabinet()
   #declare WIDTH = 0.6
   ...
#end

#macro End_Cabinet()
   union
   {
     ...
   }
#end

Begin_Cabinet()
#declare WIDTH = 0.7
End_Cabinet()

It would also remove the need for all those #ifndef's.


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 25 Jun 2009 04:30:16
Message: <4a433598@news.povray.org>
"Christian Froeschlin" <chr### [at] chrfrde> wrote in message 
news:4a42abde$1@news.povray.org...
> Chris B wrote:
>
>> The main advantage with using variables in this way is that you can 
>> specify just the variables you need
>
> Yes, I reckoned you used that mechanism for more convenient
> default values. However, it's not quite true you only need to
> specify the variables you need: you also need to reset those
> which have been modified for some previous invocation of
> the macro, and you may not always be aware of those.
>

Any identifiers defined within the macro that shouldn't persist across macro 
calls should be defined using #local rather than #declare.

It's true that any global values that you set before calling the macro the 
first time will persist across macro calls (unless you undef them), but you 
should generally be aware of what those are, because you'll usually have set 
them explicitly yourself. For things like the cabinet height, the panel 
thickness, handle type etc. this is mostly a good thing, as you can set them 
once at the top of your scene file and then generate a whole set of cabinets 
conforming to the same style. You only need to adjust the width and other 
unit-specific attributes between macro calls (door handedness, whether 
there's a sink or hob in the worksurface etc.).

There are a few situations where the macro could set a default in one 
invocation that you don't want to carry across into the next invocation. 
Where I've published macros for use by others, I've usually therefore 
included an Undef macro that can be used to reset all of the variable 
settings for which there are default values declared. This gives you the 
option of using the POV-Ray #undef command to override just that one default 
value (if you know what it's called), or calling my Undef macro to reset 
everything before the next sequence of macro calls (to be on the safe side).

For example, the Rope macros include a Rope_Undef macro. You can call that 
macro between any two Rope macro calls to Undef all of the values, so that 
you can start afresh. If the same were done here you could have a kitchen 
showroom, generating 10 units for one kitchen exhibit, then calling the 
Cabinet_Undef macro before generating 10 units in a different style for the 
next kitchen exhibit.

P.S. The #ifndef statements are really very quick to add at the end of the 
development process. Using the Windows POV-Ray editors 'columnar' editing 
feature it just takes a few seconds more work. The Undef macro is also very 
quick to create as it's mostly just a copy of the #ifndef statements with 
#ifndef changed to #ifdef and #declare changed to #undef (and the values 
removed).


> That problem could be prevented by having two macros for
> each object, the first one just resetting the defaults:
>
> #macro Begin_Cabinet()
>   #declare WIDTH = 0.6
>   ...
> #end
>
> #macro End_Cabinet()
>   union
>   {
>     ...
>   }
> #end
>
> Begin_Cabinet()
> #declare WIDTH = 0.7
> End_Cabinet()
>
> It would also remove the need for all those #ifndef's.

This comes down a little to personal preference, but I'd argue that the 
#ifndef approach makes it a little easier to generate a complete set of 
cabinets in a consistent style.

The technique you've illustrated also seems to make it more difficult to 
handle what I could call 'dependant' defaults. For example, in the Rope 
macros, the strand thickness defaults to half the rope thickness for twisted 
ropes and one third the rope thickness for braided ropes (which have twice 
the number of strands). If you only set the type of rope after calling 
Begin_Rope you don't have enough info to be able to set the default strand 
thickness within Begin_Rope.


Regards,
Chris B.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 25 Jun 2009 07:35:01
Message: <web.4a436039cfb6d60e4e47a1b0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:
> Yes, but in the modeller you need to decide which bit of a model is
> positioned at <0,0,0>.
> If you centre two differently shaped door handle models so that their
> geometric centres are at <0,0,0>, then you have to perform different
> translations to fit each of them to a door. >

 You lose me when you say "geometric centres are at <0,0,0>"

Who, What decides centres to be at <0,0,0>, when why how,

If I can figure out the answer to these, I will have rotation by the balls.

Grateful =)


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 25 Jun 2009 08:57:28
Message: <4a437438@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a436039cfb6d60e4e47a1b0@news.povray.org...
> "Chris B" <nom### [at] nomailcom> wrote:
>> Yes, but in the modeller you need to decide which bit of a model is
>> positioned at <0,0,0>.
>> If you centre two differently shaped door handle models so that their
>> geometric centres are at <0,0,0>, then you have to perform different
>> translations to fit each of them to a door. >
>
> You lose me when you say "geometric centres are at <0,0,0>"
>
> Who, What decides centres to be at <0,0,0>, when why how,
>

It's you. You do it!  Honest :-)

I've tried to explain further below, but it may be that others can explain 
differently in a way that may suit you better. So if anyone can phrase it 
differently it's probably worth posting.  I think that understanding this is 
the key to you understanding the answer to your original 
translation/rotation question.


Whenever you add a vertex into an object that you are modelling, for example 
in 3D Max, the position of that vertex is defined relative to an origin 
(position <0,0,0>). This could be in the Global coordinate system of the 
modeller, or some modellers allow you to define a Local coordinate system 
for each of the different objects that you have added into the model.

Also, whenever you add a line into a 2D drawing it is relative to some 
origin (position 0.00, 0.00), which is usually the top left or bottom left 
of the screen or page (though some applications place it in the middle of 
the page). Sometimes you don't see this in a 2D graphics application because 
it's handled behind the scenes, but any decent 2D or 3D application will 
have an option to display something to indicate the actual coordinates and 
then you can see where the origin is.

When you export an object from 3D Max, you need to know how the origin of 
the coordinate system in the generated file relates to your object. I don't 
know if an object is always written out using the Global coordinate system 
or whether 3D Max has an option to allow you to export an object using Local 
coordinate system coordinates. If you can't tell, then translating and 
rotating it, as necessary to map to the coordinate system used by your 2D 
software, becomes mind-bogglingly difficult (or degenerates to a matter of 
guesswork (sometimes called 'successive approximation')).

If you are able to control where the origin is, relative to your 3D models 
and your 2D plan, then life becomes an awful lot easier. Particularly when 
you come to mapping the 3D objects to your 2D plan and assembling all the 
bits in POV_Ray. even if you can't control the positioning of the origin you 
still need to know where the origin is to get the translations and rotations 
working right.

Regards,
Chris B.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 26 Jun 2009 04:05:00
Message: <web.4a4480b9cfb6d60e4e47a1b0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:
> It's you. You do it!  Honest :-)

Chris, I always use the box_POV_geom.inc, it's a primitive box shape sized
100X100X100 cm in 3d max and exported to PoseRay for use in POV.
it has following headers, which lines below I need to pay attention to rotate
correctly.
I know Tim Attwood explained the math necessary, but I guess I need my nose
rubbed in it. Thank you.
-----------------------------------
//Materials
#include "box_POV_mat.inc"

//Geometry
#declare box_unnamed_material_=mesh2{
vertex_vectors{
26,
<-49.999,-49.999,0.001>,
<-49.999,50.001,0.001>,
<50.001,50.001,0.001>,
<50.001,-49.999,0.001>,
<-49.999,-49.999,100.001>,
<50.001,-49.999,100.001>,
<50.001,50.001,100.001>,
<-49.999,50.001,100.001>,
<-49.999,-49.999,0.001>,
<50.001,-49.999,0.001>,
<50.001,-49.999,100.001>,
<50.001,-49.999,100.001>,
<-49.999,-49.999,100.001>,
<-49.999,-49.999,0.001>,
<50.001,50.001,0.001>,
<50.001,-49.999,100.001>,
<50.001,50.001,0.001>,
<-49.999,50.001,0.001>,
<-49.999,50.001,100.001>,
<-49.999,50.001,100.001>,
<50.001,50.001,100.001>,
<50.001,50.001,0.001>,
<-49.999,50.001,0.001>,
<-49.999,-49.999,100.001>,
<-49.999,-49.999,100.001>,
<-49.999,50.001,0.001>
}
normal_vectors{
30,
<0,0,-1>,
<0,0,-1>,
<0,0,-1>,
<0,0,-1>,
<0,0,1>,
<0,0,1>,
<0,0,1>,
<0,0,1>,
<0,-1,0>,
<0,-1,0>,
<0,-1,0>,
<0,-1,0>,
<0,-1,0>,
<0,-1,0>,
<1,0,0>,
<1,0,0>,
<1,0,0>,
<1,0,0>,
<0,1,0>,
<0,1,0>,
<0,1,0>,
<0,1,0>,
<0,1,0>,
<0,1,0>,
<-1,0,0>,
<-1,0,0>,
<-1,0,0>,
<-1,0,0>,
<-1,0,0>,
<-1,0,0>
}
uv_vectors{
26,
<1,0>,


Post a reply to this message

From: Chris B
Subject: Re: an extraordinary rotation question
Date: 26 Jun 2009 05:10:15
Message: <4a449077$1@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote in message 
news:web.4a4480b9cfb6d60e4e47a1b0@news.povray.org...
> "Chris B" <nom### [at] nomailcom> wrote:
>> It's you. You do it!  Honest :-)
>
> Chris, I always use the box_POV_geom.inc, it's a primitive box shape sized
> 100X100X100 cm in 3d max and exported to PoseRay for use in POV.
> it has following headers, which lines below I need to pay attention to 
> rotate
> correctly.
> -----------------------------------
> //Materials
> #include "box_POV_mat.inc"
>
> //Geometry
> #declare box_unnamed_material_=mesh2{
> vertex_vectors{
> 26,
> <-49.999,-49.999,0.001>,

In this instance the geometric centre of the object is centred at the 
origin. If you move the box in 3DMax so that one corner is at the origin 
instead, you may find it easier to line everything up. This doesn't make a 
very big difference with a box as the calculations are not very complex, but 
it can make a big difference when you start to model door-handles, sinks, 
taps and other asymmetrical objects.

> I know Tim Attwood explained the math necessary, but I guess I need my 
> nose
> rubbed in it. Thank you.

I hope it doesn't come across as if I'm trying to rub your nose in it. I was 
attempting to stress stuff, but still keep the conversation light, though I 
know I quite often miss my target when attempting this.


Regards,
Chris B.


Post a reply to this message

From: mysdn
Subject: Re: an extraordinary rotation question
Date: 26 Jun 2009 06:15:01
Message: <web.4a449ca6cfb6d60e4e47a1b0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:

> If you move the box in 3DMax so that one corner is at the origin
> instead, you may find it easier to line everything up

So I center the left-front corner of my box at the center while in 3d max
coordinates before exporting, I can rotate easier. I feel we are getting close
to a solution on my problem. These are the values taken from PoseRay. I think
they are the values Tim was talking about in earlier posts. Which one is
important for rotation?
box_POV_geom.inc
THIS IS FROM THE BOX EXPORTED, WITH CENTER AT <0,0,0> XYZ in MAX
//Bounding Box....... from x,y,z=(-49.999,0.001,-50.001)
//                      to x,y,z=(50.001,100.001,49.999)
//                 size dx,dy,dz=(100,100,100)
//                  center x,y,z=(0.0009994507,50.001,-0.0009994507)
//                       diagonal 173.2051
--------------------------------------------------------

THIS IS FROM THE BOX EXPORTED, WITH CENTER AT <50,50,0> XYZ in MAX

//Bounding Box....... from x,y,z=(0,0,-100)
//                      to x,y,z=(100,100,6.123032E-15)
//                 size dx,dy,dz=(100,100,100)
//                  center x,y,z=(50,50,-50)
//                       diagonal 173.2051

Now here comes the cruncher again last time, If I don't get it this time either,
I will start to think something's wrong with me. THE BIG QUESTION.


If I want to rotate the box on its y axis 45 degrees, What is the formula?
Suppose box is declared
#declare BOX = object { box_  scale <0.01,0.01,0.01> }
and it was located at translate <-50,10,0> before we will rotate it.
You should use the first centered sample above <0,0,0>, easier I think .

Your answer to this question should nail it for me. I couldn't be more greatful
for all your help so far. I know it's about centering something at the (some)
center of something's center, these centers are what gets me lost in all this.

PS: I don't care much about mesh rotations, cause they rotate anyhow, a little
off but acceptable. Cabinets and wall must rotate precisely. A chair rotated
around a table, a little off is not even noticable at first , see what I mean.
This may sound a little unprofessional but , right now my cabinet rotation
problem is monumental next to a mesh's rotation. All cabinets and walls are made
from #include  "box_POV_geom.inc"


Post a reply to this message

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