POV-Ray : Newsgroups : povray.newusers : Aligning objects Server Time
31 Jul 2024 02:26:05 EDT (-0400)
  Aligning objects (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Stephen in Calgary
Subject: Aligning objects
Date: 1 Jun 2003 03:21:59
Message: <3ed9a997$1@news.povray.org>
I have been working with PovRay for a bit now and have come to a point where
I may be spinning my wheels because I hope there is a easy way to accomplish
the following that I cannot figure out for myself.

I have an 3D object where the sides are angled to each other and then it is
rotated on a couple of axes. Right next to it, I want to place another
similar object, like bricks stacked in a crooked or non-linear wall. I can't
figure out the coordinates or normal of the side of the first object so I
can place the second object immediately ajacent.

Please tell me there are some simple routines to provide this alignment.

Thanks in advance


Post a reply to this message

From: ingo
Subject: Re: Aligning objects
Date: 1 Jun 2003 04:33:59
Message: <Xns938D6C0584594seed7@povray.org>
in news:3ed9a997$1@news.povray.org Stephen in Calgary wrote:

> I can't
> figure out the coordinates or normal of the side of the first object
> so I can place the second object immediately ajacent.
> 

If you know these points before you rotate the initial object, you can 
find their position after rotation using "vrotate".

Another option may be is using "trace".

Both are discussed in "6.1.4.6  Vector Functions"

Ingo


Post a reply to this message

From: Ib Rasmussen
Subject: Re: Aligning objects
Date: 1 Jun 2003 05:44:58
Message: <3ED9CAF8.2010804@ibras.dk>
Stephen in Calgary wrote:

> I have an 3D object where the sides are angled to each other and then it is
> rotated on a couple of axes. Right next to it, I want to place another
> similar object,


Why don't you just place the objects next to each other before you do 
the rotations, and then rotate them as a union? Or have I misunderstood 
the question?

/Ib


Post a reply to this message

From: Mike Williams
Subject: Re: Aligning objects
Date: 1 Jun 2003 10:53:37
Message: <5ney3BAcFh2+EwFP@econym.demon.co.uk>
Wasn't it Stephen in Calgary who wrote:
>I have been working with PovRay for a bit now and have come to a point where
>I may be spinning my wheels because I hope there is a easy way to accomplish
>the following that I cannot figure out for myself.
>
>I have an 3D object where the sides are angled to each other and then it is
>rotated on a couple of axes. Right next to it, I want to place another
>similar object, like bricks stacked in a crooked or non-linear wall. I can't
>figure out the coordinates or normal of the side of the first object so I
>can place the second object immediately ajacent.
>
>Please tell me there are some simple routines to provide this alignment.

It sounds like you may need to look up "trace()".

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Stephen in Calgary
Subject: Re: Aligning objects
Date: 2 Jun 2003 00:47:00
Message: <3edad6c4$1@news.povray.org>
Hi
Thanks for the feedback so far. I had looked up the suggested functions
(trace, vrotate) but hadn't yet had the opportunity to figure out if they'd
be the best tools to use.  If that's all you can suggest, then I'll
eventually get this to work for me.

What I'm trying to build is the surfaces of a rhombic dodecahedron, but more
than just the 3-D object comprised of 12 surfaces: - assume each side is
made from a piece of wood and thereby is a 3-D object in it's own right and
therefore each side is rotated and translated from the declared object at
the origin and must be aligned next to another side(s).

If you have any further hints, I'd appreciate it.

shapes.inc defines a [regular] dodecahedron as follows, this one has 12
sides made of pentagons; "mine" is 12 sided of course, but is 12 rhombi
which I defined as following next.

#declare Dodecahedron =
 intersection
  {plane {-z, 1 rotate <-26.56505117708,    0, 0>}
   plane {-z, 1 rotate <-26.56505117708,  -72, 0>}
   plane {-z, 1 rotate <-26.56505117708, -144, 0>}
   plane {-z, 1 rotate <-26.56505117708, -216, 0>}
   plane {-z, 1 rotate <-26.56505117708, -288, 0>}

   plane {-z, 1 rotate <26.56505117708,  -36, 0>}
   plane {-z, 1 rotate <26.56505117708, -108, 0>}
   plane {-z, 1 rotate <26.56505117708, -180, 0>}
   plane {-z, 1 rotate <26.56505117708, -252, 0>}
   plane {-z, 1 rotate <26.56505117708, -324, 0>}

   plane { y, 1}
   plane {-y, 1}
   bounded_by {sphere {0, 1.2585}}
  }


#declare RhombicDodecahedron =
intersection
  {
 plane { z, 1 rotate <  0,  45,  45>}
 plane { z, 1 rotate <  0,  45, -45>}
 plane { z, 1 rotate <  0, -45,  45>}
 plane { z, 1 rotate <  0, -45, -45>}

 plane {-z, 1 rotate <  0,  45,  45>}
 plane {-z, 1 rotate <  0,  45, -45>}
 plane {-z, 1 rotate <  0, -45,  45>}
 plane {-z, 1 rotate <  0, -45, -45>}

 plane {-x, 1 }
 plane { x, 1 }

 plane { y, 1}
 plane {-y, 1}
  }




"Stephen in Calgary" <signup-without-spam-@shaw.ca> wrote in message
news:3ed9a997$1@news.povray.org...
> I have been working with PovRay for a bit now and have come to a point
where
> I may be spinning my wheels because I hope there is a easy way to
accomplish
> the following that I cannot figure out for myself.
>
> I have an 3D object where the sides are angled to each other and then it
is
> rotated on a couple of axes. Right next to it, I want to place another
> similar object, like bricks stacked in a crooked or non-linear wall. I
can't
> figure out the coordinates or normal of the side of the first object so I
> can place the second object immediately ajacent.
>
> Please tell me there are some simple routines to provide this alignment.
>
> Thanks in advance
>
>


Post a reply to this message

From: JC (Exether)
Subject: Re: Aligning objects
Date: 3 Jun 2003 02:47:33
Message: <3EDC4483.4090709@spam.fr>
What exactly do you want to connect, is it the individual faces of a 
RhombicDodecahedron or several RhombicDodecahedrons ilnked by the faces ?

Anyway, more genraly, you can use vrotate as suggested (trace seems to 
me unadequate here, because it is a geometric problem and hence it has 
an exact solution), but I think it is a bit complicated. You can 
probably as Ib Rasmussen said figure out a initial position and a simple 
set of transformations that will put your objects into connection.

The reason why you can't figure it out yet is probably that there is no 
trivial way to get the initial position, you will need to calculate some 
trigonometrics formulae either to get some angles or the length of the 
sides or something like that.

I hope that helps,
If I can figure what you want I might try it,

JC


Stephen in Calgary wrote:
> Hi
> Thanks for the feedback so far. I had looked up the suggested functions
> (trace, vrotate) but hadn't yet had the opportunity to figure out if they'd
> be the best tools to use.  If that's all you can suggest, then I'll
> eventually get this to work for me.
> 
> What I'm trying to build is the surfaces of a rhombic dodecahedron, but more
> than just the 3-D object comprised of 12 surfaces: - assume each side is
> made from a piece of wood and thereby is a 3-D object in it's own right and
> therefore each side is rotated and translated from the declared object at
> the origin and must be aligned next to another side(s).
> 
> If you have any further hints, I'd appreciate it.
> 
> shapes.inc defines a [regular] dodecahedron as follows, this one has 12
> sides made of pentagons; "mine" is 12 sided of course, but is 12 rhombi
> which I defined as following next.
> 
> #declare Dodecahedron =
>  intersection
>   {plane {-z, 1 rotate <-26.56505117708,    0, 0>}
>    plane {-z, 1 rotate <-26.56505117708,  -72, 0>}
>    plane {-z, 1 rotate <-26.56505117708, -144, 0>}
>    plane {-z, 1 rotate <-26.56505117708, -216, 0>}
>    plane {-z, 1 rotate <-26.56505117708, -288, 0>}
> 
>    plane {-z, 1 rotate <26.56505117708,  -36, 0>}
>    plane {-z, 1 rotate <26.56505117708, -108, 0>}
>    plane {-z, 1 rotate <26.56505117708, -180, 0>}
>    plane {-z, 1 rotate <26.56505117708, -252, 0>}
>    plane {-z, 1 rotate <26.56505117708, -324, 0>}
> 
>    plane { y, 1}
>    plane {-y, 1}
>    bounded_by {sphere {0, 1.2585}}
>   }
> 
> 
> #declare RhombicDodecahedron =
> intersection
>   {
>  plane { z, 1 rotate <  0,  45,  45>}
>  plane { z, 1 rotate <  0,  45, -45>}
>  plane { z, 1 rotate <  0, -45,  45>}
>  plane { z, 1 rotate <  0, -45, -45>}
> 
>  plane {-z, 1 rotate <  0,  45,  45>}
>  plane {-z, 1 rotate <  0,  45, -45>}
>  plane {-z, 1 rotate <  0, -45,  45>}
>  plane {-z, 1 rotate <  0, -45, -45>}
> 
>  plane {-x, 1 }
>  plane { x, 1 }
> 
>  plane { y, 1}
>  plane {-y, 1}
>   }
> 
> 
> 
> 
> "Stephen in Calgary" <signup-without-spam-@shaw.ca> wrote in message
> news:3ed9a997$1@news.povray.org...
> 
>>I have been working with PovRay for a bit now and have come to a point
> 
> where
> 
>>I may be spinning my wheels because I hope there is a easy way to
> 
> accomplish
> 
>>the following that I cannot figure out for myself.
>>
>>I have an 3D object where the sides are angled to each other and then it
> 
> is
> 
>>rotated on a couple of axes. Right next to it, I want to place another
>>similar object, like bricks stacked in a crooked or non-linear wall. I
> 
> can't
> 
>>figure out the coordinates or normal of the side of the first object so I
>>can place the second object immediately ajacent.
>>
>>Please tell me there are some simple routines to provide this alignment.
>>
>>Thanks in advance
>>
>>
> 
> 
>


Post a reply to this message

From:
Subject: Re: Aligning objects
Date: 3 Jun 2003 21:49:29
Message: <3edd5029$1@news.povray.org>
// Hi Stephen,
//
// for texturing of the individual faces of a polyhedron you don't need
// any alignment, just give each plane of the intersection it's own pigment
// or texture and rotate it together with the plane. In the following
// declaration of a RhombicDodecahedron, replace the texture statements
// by your textures for the faces. For each of these textures, the area
// in the xy-plane with corners
//
//                sqrt(.5)*y
//    -x                              x
//               -sqrt(.5)*y
//
// is transferred to the face to which this texture belongs.
//
// I've added spheres in the corners; it's easy to calculate midpoints
// and face normals from their coordinates.
//
//    Sputnik
//
//
// ----------------------------

// fr### [at] computermuseumfh-kielde
// ----------------------------


// finish, textures =====================================================

#declare Fin = finish { ambient .4 diffuse .6 }

#declare Wood = texture {
  pigment { wood scale 0.05 rotate 87*y translate -0.3*z }
  finish { Fin }
  }

#declare Test = texture {
  pigment { image_map { png "test" } // test.png is in include directory
    translate <-0.5, -0.5, 0>
    scale <2, sqrt(2), 1>
    }
  finish { Fin }
  }


// declaration of rhombic dodecahedron ==================================

#declare RhombicDodecahedron =
  intersection {
    plane { -z, 0 texture { Wood } translate -z rotate <  0, 45, 45> }
    plane { -z, 0 texture { Test } translate -z rotate <  0, 45,-45> }
    plane { -z, 0 texture { Test } translate -z rotate <  0,-45, 45> }
    plane { -z, 0 texture { Test } translate -z rotate <  0,-45,-45> }

    plane { -z, 0 texture { Test } translate -z rotate <  0,225,-45> }
    plane { -z, 0 texture { Test } translate -z rotate <  0,225, 45> }
    plane { -z, 0 texture { Test } translate -z rotate <  0,135,-45> }
    plane { -z, 0 texture { Test } translate -z rotate <  0,135, 45> }

    plane { -z, 0 texture { Wood } translate -z rotate < 90,  0,  0> }
    plane { -z, 0 texture { Test } translate -z rotate < 90,  0, 90> }
    plane { -z, 0 texture { Test } translate -z rotate < 90,  0,180> }
    plane { -z, 0 texture { Test } translate -z rotate < 90,  0,-90> }

    bounded_by { sphere { 0, 1.42 } }

    }//intersection


// declaration of corners of rhombic dodecahedron =======================

#declare S = sqrt(.5);
#declare R = .05;
#declare Corners =
  union {
    union {
      sphere { < 0,  1,  S>, R }
      sphere { < 0,  1, -S>, R }
      sphere { < 0, -1,  S>, R }
      sphere { < 0, -1, -S>, R }
      sphere { < 1,  0,  S>, R }
      sphere { < 1,  0, -S>, R }
      sphere { <-1,  0,  S>, R }
      sphere { <-1,  0, -S>, R }
      texture { pigment { color blue 1 } finish { Fin } }
      }
    union {
      sphere { < 1,  1,  0>, R }
      sphere { < 1, -1,  0>, R }
      sphere { <-1,  1,  0>, R }
      sphere { <-1, -1,  0>, R }
      sphere { < 0,  0,  2*S>, R }
      sphere { < 0,  0, -2*S>, R }
      texture { pigment { color red 1 } finish { Fin } }
      }
    }


// calculate an midpoint, here normal vector = midpoint vector ==========

#declare Mid = ( <0, 1, -S> + <1, 0, -S> ) / 2; // =<0.5, 0.5, S>
// midpoints:  <+/- 0.5, +/- 0.5, +/- S>;  x;  -x;  y;  -y


// simple scene with textured rhombic dodecahedron etc. on plane ========

union {
  object { RhombicDodecahedron }
  object { Corners }
  cone { 0, 0.05, -0.8*z, 0
    texture { pigment { color green 1 } finish { Fin } }
    rotate <0, -45, 45> //or: transform { Reorient_Trans (-x, Mid) }
    translate Mid
    }
  scale 1 rotate 0*y translate <0, 0, 0>
  }

plane { y, -1-R
  texture {
    pigment { checker rgb <1, .9, .8>, rgb <.8, .7, .6> }
    finish { Fin }
    }
  }

light_source { <-1500, 2500, -2000>, color rgb 1 }

camera { location -10*z look_at 0 angle 20
  rotate <25, 20, 0> translate <0, 0, 0> }


// END ==================================================================


Post a reply to this message

From: Stephen in Calgary
Subject: Re: Aligning objects
Date: 5 Jun 2003 13:33:00
Message: <3edf7ecc$1@news.povray.org>
Hi, I'm still working on some of the tools and information written already,
but I thought I would share with you the source of my interest in
specifically rhombic dodecahedrons. I appreciate the input so far.

In this particular context I am a software engineer + amature woodworker, so
I have built some of these puzzles and as an exercise in learing POVRay by
trying to model the same structures as if they were built by 3D "boards"
rather than the rendering infinitely thin plane or solid object
constructions for simply the purpose of a graphic image.

The basic problems I'm having and trying to learn solutions to are related
rotating objects in more than one plane and determining the exact
coordinates of a face of an object so I can align another object right
there.

Check this site if you have an interest in puzzles, particularly wooden
constructions:
http://johnrausch.com/PuzzleWorld/puz/pennyhedron.htm



"Stephen in Calgary" <signup-without-spam-@shaw.ca> wrote in message
news:3ed9a997$1@news.povray.org...
> I have been working with PovRay for a bit now and have come to a point
where
> I may be spinning my wheels because I hope there is a easy way to
accomplish
> the following that I cannot figure out for myself.
>
> I have an 3D object where the sides are angled to each other and then it
is
> rotated on a couple of axes. Right next to it, I want to place another
> similar object, like bricks stacked in a crooked or non-linear wall. I
can't
> figure out the coordinates or normal of the side of the first object so I
> can place the second object immediately ajacent.
>
> Please tell me there are some simple routines to provide this alignment.
>
> Thanks in advance
>
>


Post a reply to this message

From: Ken
Subject: Re: Aligning objects
Date: 5 Jun 2003 20:53:41
Message: <3EDFE679.56361243@pacbell.net>
Stephen in Calgary wrote:

> Check this site if you have an interest in puzzles, particularly wooden
> constructions:
> http://johnrausch.com/PuzzleWorld/puz/pennyhedron.htm

The owner of this site is also a POV-Ray user -
http://www.puzzlecraft.com/

:)

-- 
Ken Tyler


Post a reply to this message

From:
Subject: Re: Aligning objects
Date: 6 Jun 2003 18:56:37
Message: <3ee11c25$1@news.povray.org>
// Hi Stephen,
//
// here is some more rhombic dodecahedron (r.d.) stuff, now with faces
// as individual objects, and with macros to put arbitrary objects
// onto a face. The xy-area mentioned in my last post matches the
// face, the points with positive z will go to the inside (so face
// objects should have z<=0), points with negative z will go to the
// outside (this way objects are attached to a face).
// The other maco puts objects on the xz-plane onto a face; -y goes
// to inside, y to outside.
//
// Of course an r.d. with attached r.d.'s may itself be attached to
// an r.d., and so on ...
//
//
//    Sputnik
//
//
// ----------------------------

// fr### [at] computermuseumfh-kielde
// ----------------------------


// finish, textures =====================================================


#declare Fin =
  finish {
    ambient 0.3
    diffuse 0.5
    specular .2 roughness .02
    }

#declare Wood1 =
  texture {
    pigment { wood
      ramp_wave
      color_map { [.45 rgb <.95, .90, .55> ]
                  [.55 rgb <.80, .65, .35> ] }
      turbulence <0.06, 0.01, 0.06> octaves 1
      scale 0.05 rotate 87*y translate -0.3*z
      }
    finish { Fin }
    }

#declare Wood2 =
  texture {
    pigment { wood
      ramp_wave
      color_map { [ 0 rgb <.75, .45, .2> ]
                  [.8 rgb <.50, .22, .1> ] }
      turbulence <0.06, 0.01, 0.06>
      scale 0.05 rotate 87*y translate -0.3*z
      }
    finish { Fin }
    }

#declare Test = texture {
  pigment { image_map { png "test" } // test.png is in include directory
    translate <-0.5, -0.5, 0>
    scale <2, sqrt(2), 1>
    }
  finish { Fin }
  }


// macros and declarations for rhombic dodecahedron =====================


// macro to put an object on xy-plane onto a face
// z goes inside, -z goes outside
#macro Put_xy_onto_face ( Object, Rotation )
  object { Object translate -z rotate Rotation }
  #end//macro Put_onto_face


// macro to put an object on xz-plane onto a face
// -y goes inside, y goes outside
#macro Put_xz_onto_face ( Object, Rotation )
  object { Object translate y rotate Rotation-90*x }
  #end//macro Put_onto_face


// macro to create rounded objects for faces
#macro Face ( Round )
  #local X = <1-sqrt(3)*Round, 0>;
  #local Y = <0, (1-sqrt(3)*Round)*sqrt(.5)>;
  union {
    sphere   {-X,    Round }
    cylinder {-X, Y, Round }
    sphere   { Y,    Round }
    cylinder { Y, X, Round }
    sphere   { X,    Round }
    cylinder { X,-Y, Round }
    sphere   {-Y,    Round }
    cylinder {-Y,-X, Round }
    prism { linear_spline -Round, Round, 5, -X, Y, X, -Y, -X
      rotate 90*x
      }
    translate Round*z
    // no "}" to allow application of texture etc.
  #end//macro Face


// some face objects; scale .96 found by experimentation ...
#declare Face1 = Face(.03) scale .96
  texture { Wood1 rotate degrees(atan(sqrt(.5)))*z }
  }

#declare Face2 = Face(.03) scale .96
  texture { Wood2 rotate degrees(atan(sqrt(.5)))*z }
  }

#declare Face3 = Face(.2 ) scale 1
  texture { Wood1 rotate degrees(atan(sqrt(.5)))*z }
  }

#declare Face4 = sphere { z, 1 scale <sqrt(.5), .5, .01> texture { Test } }


#declare RhomDo1 =
  union {
    Put_xy_onto_face ( Face1, <  0, 45, 45> ) // front, lower left
    Put_xy_onto_face ( Face2, <  0, 45,-45> ) // front, upper left
    Put_xy_onto_face ( Face1, <  0,-45, 45> ) // front, upper right
    Put_xy_onto_face ( Face2, <  0,-45,-45> ) // front, lower right
    Put_xy_onto_face ( Face3, <  0,225,-45> ) // back, lower right
    Put_xy_onto_face ( Face4, <  0,225, 45> ) // back, upper right
    Put_xy_onto_face ( Face3, <  0,135,-45> ) // back, upper left
    Put_xy_onto_face ( Face4, <  0,135, 45> ) // back, lower left
    Put_xy_onto_face ( Face1, < 90,  0,  0> ) // top
    Put_xy_onto_face ( Face2, < 90,  0, 90> ) // left
    Put_xy_onto_face ( Face1, < 90,  0,180> ) // bottom
    Put_xy_onto_face ( Face2, < 90,  0,-90> ) // right
    }


#declare RhomDo2 =
  union {
    object { RhomDo1 }
    Put_xz_onto_face ( object { RhomDo1 translate y }, <  0,-45, 45> )
    Put_xz_onto_face ( object { RhomDo1 translate y }, <  0,225, 45> )
    Put_xz_onto_face ( object { RhomDo1 translate y }, <  0,135,-45> )
    }


// simple scene with textured rhombic dodecahedrons etc. on plane =======


object { RhomDo1 scale .5 translate <-1, 0.5, 0> }

object { RhomDo2 scale .5 translate <0.8, 0.5, 1> }

#declare Rand = seed(876);
#declare Snake = RhomDo1;
#declare I = 0;
#while (I<15)
  #declare Snake =
    union {
      // get a new RhomDo
      object { RhomDo1 }
      // put on one of it's upper faces the snake created so far:
      Put_xz_onto_face (
        // get the snake so far (centered around 0)
        object  { Snake
          // put onto xz-plane pointing to y
          translate y },
          // choose one of the upper fife faces
          #switch (rand(Rand))
            #range(0  , .15) <  0, 45,-45> ) #break
            #range(.15, .3 ) <  0,-45, 45> ) #break
            #range(.3 , .45) <  0,225, 45> ) #break
            #range(.45, .6 ) <  0,135,-45> ) #break
            #else            < 90,  0,  0> )
            #end//switch
      }//union
  #declare I = I+1;
  #end//while I

object { Snake translate y scale 0.1 rotate 0*y translate <-0.2, 0, -0.7> }


plane { y, 0
  texture {
    pigment { checker rgb <1, .9, .8>, rgb <.8, .7, .6> }
    finish { Fin }
    }
  }

light_source { <-1500, 2500, -2000>, color rgb 1 }

camera { location -10*z look_at 0 angle 20
  rotate <25, 20, 0> translate <0, 1, 0> }


// END ==================================================================


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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