POV-Ray : Newsgroups : povray.advanced-users : Tricky object alignment problem Server Time
28 Jul 2024 14:22:24 EDT (-0400)
  Tricky object alignment problem (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Rune
Subject: Re: A solution
Date: 28 May 2006 11:11:55
Message: <4479bdbb$1@news.povray.org>
Orchid XP v2 wrote:
> This seems to work...
>
> In case it way be of use to anybod else...

Could you provide an example of use? I can't get it to work in the test 
scene below. Granted, it doesn't use a parallelogram, but it looks like it 
is meant to handle other coplanar points too. Besides, doesn't work with a 
parallelogram either. If you really need it for parallelograms only, then I 
can think of a simpler solution that uses a box instead of a prism.

#include "transforms.inc"

#macro Rectangle(A, B, C, D, r)
   sphere {A, r}
   sphere {B, r}
   sphere {C, r}
   sphere {D, r}
   cylinder {A, B, r}
   cylinder {B, C, r}
   cylinder {C, D, r}
   cylinder {D, A, r}
#end

#macro DrawPoly(Points, Radius)
   #local A = Points[0];
   #local B = Points[1];
   #local C = Points[2];

   #local AB = B - A;
   #local AC = C - A;
   #local Norm = vnormalize(vcross(AB, AC));

   #local V1 = Norm;
   #local V2 = vnormalize(AB);
   #local V3 = vcross(V1, V2);

   prism
   {
     linear_sweep
     linear_spline
     -Radius, +Radius, dimension_size(Points, 1),

     #local lp = 0;
     #while (lp < dimension_size(Points, 1))
       <vdot(V3, Points[lp]), vdot(V2, Points[lp])>

       #local lp = lp + 1;
     #end

     translate +y*vdot(A, Norm)
     Reorient_Trans(y, Norm)
   }
#end

#declare Points = array[4] {<-1,-1,0>, <1,-2,1>, <1,2,1>, <-1,2,0>}

camera {location -6*z}
light_source {<-1,2,-3>*1000, color rgb 1}

union {
   Rectangle(Points[0],Points[1],Points[2],Points[3], 0.3)
   DrawPoly(Points, 0.3)
   pigment {rgb 1}
}


Rune
-- 
http://runevision.com


Post a reply to this message

From: Orchid XP v2
Subject: Re: A solution
Date: 3 Jun 2006 15:09:56
Message: <4481de84@news.povray.org>
>>This seems to work...
>>
>>In case it way be of use to anybod else...
> 
> 
> Could you provide an example of use? I can't get it to work in the test 
> scene below. Granted, it doesn't use a parallelogram, but it looks like it 
> is meant to handle other coplanar points too. Besides, doesn't work with a 
> parallelogram either. If you really need it for parallelograms only, then I 
> can think of a simpler solution that uses a box instead of a prism.

It *is* supposed to work for any polygone. Apparently it doesn't...

Please rip out the line at the end of DrawPoly() that says

   Reorient_Trans(y, Norm)

and replace it with

   Shear_Trans(V3, V1, V2)

Let me know if that fixes the problem...


Post a reply to this message

From: Rune
Subject: Re: A solution
Date: 6 Jun 2006 07:28:31
Message: <448566df$1@news.povray.org>
Orchid XP v2 wrote:
> It *is* supposed to work for any polygone. Apparently it doesn't...
>
> Please rip out the line at the end of DrawPoly() that says
>
>   Reorient_Trans(y, Norm)
>
> and replace it with
>
>   Shear_Trans(V3, V1, V2)
>
> Let me know if that fixes the problem...

It seems to fix it. :)

Rune
-- 
http://runevision.com


Post a reply to this message

From: Orchid XP v2
Subject: Re: A solution
Date: 7 Jun 2006 13:42:36
Message: <4487100c$1@news.povray.org>
>>Let me know if that fixes the problem...
> 
> 
> It seems to fix it. :)

Introduces an extra rotation that just happens not to be necessary in 
the special case I had when I designed the thing. ;-)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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