POV-Ray : Newsgroups : povray.general : union of door and handle pushes item off z axis : Re: union of door and handle pushes item off z axis Server Time
30 Jul 2024 06:25:14 EDT (-0400)
  Re: union of door and handle pushes item off z axis  
From: Alain
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

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