POV-Ray : Newsgroups : povray.general : union of door and handle pushes item off z axis Server Time
5 Nov 2024 01:25:25 EST (-0500)
  union of door and handle pushes item off z axis (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: optima
Subject: union of door and handle pushes item off z axis
Date: 23 Aug 2009 18:05:00
Message: <web.4a91bcada4a76a44e1fab65c0@news.povray.org>
Hi,
When I open the door of cabinet, say 45o, the cabinet is pushed back along z
axis. If the door is closed, zero rotation, problem disappears. So it has to do
something with rotations inside a union of 5-6 objects.
I guess the object order or rotation placement is wrong in the Union.
I couldn't figure out the solution, if someone was kind enough to offer some
help, I will appreciate it very much. Thanks a lot.

Why is the cabinet on the right is pushed back when its door is opened?

sample is at http://www.kitchendesigned.com/download/handle.zip

Ibrahim Dogan


Post a reply to this message

From: Alain
Subject: Re: union of door and handle pushes item off z axis
Date: 24 Aug 2009 13:53:04
Message: <4a92d380$1@news.povray.org>

> Hi,
> When I open the door of cabinet, say 45o, the cabinet is pushed back along z
> axis. If the door is closed, zero rotation, problem disappears. So it has to do
> something with rotations inside a union of 5-6 objects.
> I guess the object order or rotation placement is wrong in the Union.
> I couldn't figure out the solution, if someone was kind enough to offer some
> help, I will appreciate it very much. Thanks a lot.
> 
> Why is the cabinet on the right is pushed back when its door is opened?
> 
> sample is at http://www.kitchendesigned.com/download/handle.zip
> 
> Ibrahim Dogan
> 
> 
> 
> 

It realy look like a bad grouping of the union's components.

The door's rotation should ONLY affect the door itself and any element 
that are ON the door.
You need to use nested unions.
Your union *should* look like:

union{// First, the "static" objects
	object {Cabinet rotate Some_Rotation translate Some_position}
	union {// then the door and components.
		object{Door}
		object{Door_handle}//things that must moove with the door
		onject{Door_Decorations}
		rotate Door_opening translate Door_Location
		}
	}

Note: The door and it's handle and decoration can be defines as a 
complete object:
#declare Door_Complete = 
union{object{Door}object{Handle}object{Decorations}}

It's best to declare the door with the AXIS of it's hinges along the Y 
axis. It will be much easier to place it.


Alain


Post a reply to this message

From: optima
Subject: Re: union of door and handle pushes item off z axis
Date: 24 Aug 2009 16:05:01
Message: <web.4a92f255b4a77fd0e1fab65c0@news.povray.org>
> >
>
> It realy look like a bad grouping of the union's components.

Alain, thank you for your response, I appreciate it. I think you are right it is
a bad Union strategy I employ in my sample. Instead of only the door rotating,
the whole object moves. I will work on it some more and let you know when I
have it working right. Thanks again.

Ibrahim


Post a reply to this message

From: optima
Subject: Re: union of door and handle pushes item off z axis
Date: 24 Aug 2009 16:45:00
Message: <web.4a92fb08b4a77fd0e1fab65c0@news.povray.org>
I took 3 different approaches to the problem with no success. Let me define the
problem in simpler terms for everyone to grasp at first look.

How do we rotate 2 combined objects (door and handle) inside a Union?

I tried
1- #declare Door_Handle =
union{object{Door}object{Handle}}
   // as a separate object

2- another union (for door and handle) inside the main union

3- everything in a single union (with door and handle rotated)

in all 3 cases the cabinet moves back by a visible margin.

I'm stuck, I want to do it in a single or 2 nested unions. What can I do?
Thank you, any kind of help will be appreciated a lot.


Post a reply to this message

From: optima
Subject: Re: union of door and handle pushes item off z axis
Date: 25 Aug 2009 04:55:00
Message: <web.4a93a598b4a77fd0e1fab65c0@news.povray.org>
I got it with the code shown below, thank you. I hope this is the best way to
assemble a cabinet in povray code. I extracted the solution from povray's
woodbox sample. Alain's help was encouraging also.

#declare door = object{ model_101_ scale <0.01,0.01,0.8> scale
<49.4999961853027,75,1> translate <25,-1,61> pigment {image_map {jpeg
"A333_bergama.jpg"} scale 1} finish {phong 1 ambient 0.6 reflection 0.08}
  translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>
 }


#declare handle = object {k_model_1_ pigment {image_map {jpeg "A316_wenge.jpg"}
scale 1}
scale <0.1,0.1,0.1> rotate z*0
translate <3,62,64>finish {phong 1 ambient 0.3 reflection 0.3}//a2
}


#declare cabinetcase = union{
object{ BOX scale <50,2,60> translate <25,0,0> pigment {color rgb <1,1,1>}}
object{ BOX scale <2,73,58> translate <49,37.5,2> pigment {color rgb <1,1,1>}}
object{ BOX scale <2,73,58> translate <1,37.5,2> pigment {color rgb <1,1,1>}}
object{ BOX scale <50,73,2> translate <25,37.5,0> pigment {color rgb <1,1,1>}}

}//close union

 //FINALLY PUT EVERYTHING TOGETHER
union {
object { cabinetcase  }
object { door  }
object { handle  }

 translate x*62   rotate -y*35
     }


Post a reply to this message

From: Alain
Subject: Re: union of door and handle pushes item off z axis
Date: 25 Aug 2009 21:27:57
Message: <4a948f9d$1@news.povray.org>

> I got it with the code shown below, thank you. I hope this is the best way to
> assemble a cabinet in povray code. I extracted the solution from povray's
> woodbox sample. Alain's help was encouraging also.
> 
> #declare door = object{ model_101_ scale <0.01,0.01,0.8> scale
> <49.4999961853027,75,1> translate <25,-1,61> pigment {image_map {jpeg
This translate should be used to align the door relative to the Y axis.
> "A333_bergama.jpg"} scale 1} finish {phong 1 ambient 0.6 reflection 0.08}
>   translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>
Remove this line.
>  }
A rotation here will only rotate the door. It will not affect anything 
attached to it.
----> don't rotate here!

Make sure that one edge, preferably the hinge axis, of the door lies ON 
the Y axis.

> 
> 
> #declare handle = object {k_model_1_ pigment {image_map {jpeg "A316_wenge.jpg"}
> scale 1}
> scale <0.1,0.1,0.1> rotate z*0
> translate <3,62,64>finish {phong 1 ambient 0.3 reflection 0.3}//a2
> }
This must be located relative to the door at it's starting location.
> 
> 
> #declare cabinetcase = union{
> object{ BOX scale <50,2,60> translate <25,0,0> pigment {color rgb <1,1,1>}}
> object{ BOX scale <2,73,58> translate <49,37.5,2> pigment {color rgb <1,1,1>}}
> object{ BOX scale <2,73,58> translate <1,37.5,2> pigment {color rgb <1,1,1>}}
> object{ BOX scale <50,73,2> translate <25,37.5,0> pigment {color rgb <1,1,1>}}
> 
> }//close union
> 
>  //FINALLY PUT EVERYTHING TOGETHER
> union {
> object { cabinetcase  }
> object { door  }
> object { handle  }
> 
>  translate x*62   rotate -y*35
This rotation will affect EVERYTHING in the union and make it orbit 
around the origin. Very probably the cause of your unexpected movements.
>      }
> 
> 
> 

New union:
union{
	object { cabinetcase  }
	union{ // for the door itself
		object { door  }
		object { handle  }
		rotate Door_Opening
// This will rotate ONLY the door and it's decorations
		translate Door_Location
// To place the door at it's final location
		}
	rotate Cabinet_Rotation
// To align the cabinet to a wall or some thing
	translate Cabinet_Location
// Final placement of the whole cabinet
	}

Remember to rotate THEN translate.

If you translate then rotate, the rotation will cause the object to 
change position. Usefull if you want to place several objects in a circle.



Alain


Post a reply to this message

From: optima
Subject: Re: union of door and handle pushes item off z axis
Date: 26 Aug 2009 04:00:01
Message: <web.4a94ea56b4a77fd0e1fab65c0@news.povray.org>
Alain, thank for your explanatory answer, a few points remain

1 - With the code below I cant open the door, where to place the opening code?

#declare door = object{ model_101_ scale <0.01,0.01,0.8> scale
<49.4999961853027,75,1> translate <25,0,61> pigment {image_map {jpeg
"A333_bergama.jpg"} scale 1} finish {phong 1 ambient 0.6 reflection 0.08}

  //translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>

}



//> This must be located relative to the door at it's starting location.
#declare handle = object {k_model_1_ pigment {image_map {jpeg "A316_wenge.jpg"}
scale 1}//a1
scale <0.1,0.1,0.1> rotate z*0
translate <47,62,64>finish {phong 1 ambient 0.3 reflection 0.3}}//a2
//translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>}//b2



//New union:
 union{
  object { cabinetcase  }
  union{ // for the door itself
   object { door  }
   object { handle  }
     rotate y*45 //Door_Opening
 // This will rotate ONLY the door and it's decorations
   translate -<0,0,0>//Door and Handle Location
 // To place the door at it's final location
   }
  rotate y*0//Cabinet_Rotation
 // To align the cabinet to a wall or some thing
  translate <-0,0,0>   rotate <0,0,0>//Cabinet_Location
 // Final placement of the whole cabinet
  }

2 - You say,
  Make sure that one edge, preferably the hinge axis, of the door lies ON
the Y axis. How, I don't get it? I guess because of that the above union don't
work.



3 -You say
  translate <-0,0,0>   rotate <0,0,0>//Cabinet_Location
 // Final placement of the whole cabinet

Is it better to use min max extent for final placements?
#declare CentrePoint = (min_extent( altdolap1kpk2 )+max_extent(altdolap1kpk2
))/2;
object { altdolap1kpk2 translate -CentrePoint rotate <0,0,0> translate
<-170.5,47.5,134.5>}


Thank you million times.....


Post a reply to this message

From: Alain
Subject: Re: union of door and handle pushes item off z axis
Date: 27 Aug 2009 21:04:53
Message: <4a972d35$1@news.povray.org>
Normaly, I make the following assumptions:
The y axis is vertical.
The x-z plane is the reference plane. The base level of the top surface 
of the floor.

Not assumptions:
With that, furnitures are defined with all Y coordinate been zero or 
positive. You don't need to translate then to place them on the floor.
Free standing object are idealy defined centered around the Y axis. We 
instinctively see them rotate around ther center.
Doors are beter defined with an edge along the Y axis.
Traps with an edge along the X or Z axis. We naturaly see them as 
rotating around an axis.
Big furnitures, such as cabinets with the back side along the X-y or the 
Z-Y plane, centered on the Y axis. To make them easier to place along 
the walls.


> Alain, thank for your explanatory answer, a few points remain
> 
> 1 - With the code below I cant open the door, where to place the opening code?
> 
> #declare door = object{ model_101_ scale <0.01,0.01,0.8> scale
> <49.4999961853027,75,1> translate <25,0,61> pigment {image_map {jpeg
> "A333_bergama.jpg"} scale 1} finish {phong 1 ambient 0.6 reflection 0.08}
> 
>   //translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>
> 
> }
This is NOT the place from where you open the door. This is the place 
where you define the door at it's starting location and orientation.
If you have several doors, you don't always want all of them to open the 
same way at the same time. Say you have 10 Large cabinets, each with 
with 10 identical doors and you want to open only one of them, or have 
some doors opened, but at different angles, if you set the opening here, 
you'll have some problem: 99 doors that you want closed will open.
> 
> 
> 
> //> This must be located relative to the door at it's starting location.
> #declare handle = object {k_model_1_ pigment {image_map {jpeg "A316_wenge.jpg"}
> scale 1}//a1
> scale <0.1,0.1,0.1> rotate z*0
> translate <47,62,64>finish {phong 1 ambient 0.3 reflection 0.3}}//a2
> //translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>}//b2
> 
> 
> 
You open the door in the following location.
I prefer to use a variable to set the angle of the opening.
#declare Door_Opening = <0,45,0>;
OR
#declare Door_Opening = 45*y;

> //New union:
>  union{
>   object { cabinetcase  }
>   union{ // for the door itself
>    object { door  }
>    object { handle  }
>      rotate y*45 //Door_Opening
>  // This will rotate ONLY the door and it's decorations
>    translate -<0,0,0>//Door and Handle Location
>  // To place the door at it's final location
>    }
>   rotate y*0//Cabinet_Rotation
>  // To align the cabinet to a wall or some thing
>   translate <-0,0,0>   rotate <0,0,0>//Cabinet_Location
>  // Final placement of the whole cabinet
>   }
> 
> 2 - You say,
>   Make sure that one edge, preferably the hinge axis, of the door lies ON
> the Y axis. How, I don't get it? I guess because of that the above union don't
> work.
If the door is not defined with an edge ON the y axis, it will orbit 
around the y axis.
> 
> 
> 
> 3 -You say
>   translate <-0,0,0>   rotate <0,0,0>//Cabinet_Location
>  // Final placement of the whole cabinet
> 
> Is it better to use min max extent for final placements?
> #declare CentrePoint = (min_extent( altdolap1kpk2 )+max_extent(altdolap1kpk2
> ))/2;
> object { altdolap1kpk2 translate -CentrePoint rotate <0,0,0> translate
> <-170.5,47.5,134.5>}

No. Not in this case. As the cabinet itself is defined at a known 
location in a known orientation, you don't need to find it's location.
Idealy, you defined the cabinet with it's base on the x-z plane and 
centered around the y axis, or with one corner along that axis.
As you used a box as the base, all it's edges are parallel to the axis.

If that's the case, you don't need to translate along the y axis unless 
you want to place it on some raised or sunked part.
You only need to move it to place it along some wall.

min_extent() and max_extent() are mostly usefull when you are not sure 
of the dimentions and placement of an object and want to place it 
precisely along other objects,

> 
> 
> Thank you million times.....
> 
> 

One of your problem seems to be that the door is not defined with one of 
it's edge ON an axis. You should then translate the door once in it's 
definition to acheive that alighment.

You can use max_extent(Door) and min_extent(Door) to find the bounding 
box of the door. From that, you can find the edge that should be used as 
the rotation axis to use to open the door.
It's probable that the x-y part of min_extent correspond to the corner 
that interest you. If you translate by -min_extent(Door), the bottom, 
front left corner will be moved at <0,0,0>.
You can do this after Door have been defined:
#declare Door = object{Door translate -min_extent(Door)}

A side note: When, in an CSG operation, you have several objects that 
share the same plain pigment, it's beter to apply that pigment to the 
whole thing instead of applying it to each component.

It's easier to read and maintain. A component that have it's own texture 
is then obviously a part that have a different texture than the rest.



Alain


Post a reply to this message

From: optima
Subject: Re: union of door and handle pushes item off z axis
Date: 28 Aug 2009 11:15:00
Message: <web.4a97f3a5b4a77fd044cee4d70@news.povray.org>
Alain, thanks to you and your samples, I got the door to rotate correctly with
the code below.

//DECLARE DOOR AND HANDLE, (case is defined separately "altdolap1kpk")
#declare model_101_ = object{ model_101_ scale <0.01,0.01,0.8> }
#declare k_model_1_ = object {k_model_1_ scale <0.1,0.1,0.1> }

//PLACE CABINETS IN SCENE
union{
object { altdolap1kpk }
union{
object { model_101_ scale <39.4999961853027,75,1> translate <20,0,61> pigment
{image_map {jpeg "Blue.jpg"} scale 1} finish {phong 1 ambient 0.6 reflection
0.08} }
object { k_model_1_ rotate z*0 translate <37,62,64> pigment {image_map {jpeg
"a700.jpg"} scale 1} finish {phong 1 ambient 0.3 reflection 0.3} }
translate -<0,47.5,60> rotate y*-0 translate <0,47.5,60>}//ROTATE DOOR
translate -<0,0,0> rotate <0,0,0> translate -<0,0,0>//TO ROTATE WHOLE CABINET

translate <-50,0,0>}

Thanks to everybody helping me before the DOOR problem is solved with above
code. Now I got a second problem, I want to rotate the cabinet on its on y axis
(turn left or right) but it orbits again. I can only rotate objects on their y
axis 90-180-270 degrees cause I change their width and depth values with each
other in the translate statement. But I know this is wrong...
How do I rotate my cabinet or any object in place. How would you rotate the
above cabinet 34 degrees with values given above?

Note: I have been using povray for a year now, I still can't rotate objects in
place without orbiting? Sorry if I'm slow to understand. Thanks again.


Post a reply to this message

From: Alain
Subject: Re: union of door and handle pushes item off z axis
Date: 29 Aug 2009 15:28:08
Message: <4a998148$1@news.povray.org>


> Thanks to everybody helping me before the DOOR problem is solved with above
> code. Now I got a second problem, I want to rotate the cabinet on its on y axis
> (turn left or right) but it orbits again. I can only rotate objects on their y
> axis 90-180-270 degrees cause I change their width and depth values with each
> other in the translate statement. But I know this is wrong...
> How do I rotate my cabinet or any object in place. How would you rotate the
> above cabinet 34 degrees with values given above?
> 
> Note: I have been using povray for a year now, I still can't rotate objects in
> place without orbiting? Sorry if I'm slow to understand. Thanks again.
> 
> 
> 

Anytime you get your objects orbiting when you rotate them, it's because 
they are not created at the origin, or you have positioned them before 
the rotation.

A cabinet should be modeled with it's back having a zero coordinate and 
sit on the grouns: 0-> +Y.
A door should have an edge along the Y axis.
A trap with an adge along the X or Z axis.
Furnitures and objects destined to stand on something should extend from 
the X-Z plane toward +Y and be located around the Y axis.
Other objects should sit around the origin.

So, before you rotate the object, be sure it's sitting at the correct 
place. Never translate from the origin before you rotate.

1 - Create all objects AT the origin.
2 - Scale the object as needed.
3 - Rotate the object as needed.
4 - Translate the object to it's final location.

Alain


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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