POV-Ray : Newsgroups : povray.general : Connect 2 points with a box Server Time
20 Nov 2024 02:38:25 EST (-0500)
  Connect 2 points with a box (Message 1 to 7 of 7)  
From: Martin Thoma
Subject: Connect 2 points with a box
Date: 29 Nov 2001 03:07:54
Message: <3C05EC9D.8C9DC97F@radiok2r.de>
Hello!

I have connected 2 points in space with a cylinder, which works fine:

  cylinder{<xv1, yv1, zv1>,
               <xv2, yv2, zv2>,
              0.5
            texture { B2 }
    }

What I now need is to replace the cylinder with a box. The box sould be
a kind of a thin plate, lets say width=2, depth=0.5, and it should be
rotated that it start-point is <xv1, yv1, zv1> and its end-point is
<xv2, yv2, zv2>. This points should be centered in width and depth.

Any idea, how I can calculate the 2 points of a box out of this
information?

Thanx in advance.

Martin


Post a reply to this message

From: Christoph Hormann
Subject: Re: Connect 2 points with a box
Date: 29 Nov 2001 03:24:06
Message: <3C05F0A7.21C964B@gmx.de>
Martin Thoma wrote:
> 
> Hello!
> 
> I have connected 2 points in space with a cylinder, which works fine:
> 
> [...]
> 
> What I now need is to replace the cylinder with a box. The box sould be
> a kind of a thin plate, lets say width=2, depth=0.5, and it should be
> rotated that it start-point is <xv1, yv1, zv1> and its end-point is
> <xv2, yv2, zv2>. This points should be centered in width and depth.
> 
> Any idea, how I can calculate the 2 points of a box out of this
> information?
> 

Check the 'Reorient_Trans()' macro in Povray 3.5.

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Martin Thoma
Subject: Re: Connect 2 points with a box
Date: 29 Nov 2001 05:44:11
Message: <3C06113E.4635A40B@radiok2r.de>
Hi Christoph,

thanx for your answer, but it doesn't work:

       #declare a1 = <0, 1, 0>;
       #declare a2 = <xv3-xv1, yv3-yv1, zv3-zv1>;

        Reorient_Trans(a1, a2);

Gives me an Error in transforms.inc:

...
File: C:\Programme\POV-Ray for Windows v3.5\INCLUDE\transforms.inc  Line: 84
        #local vZ2 = vnormalize(vcross(vX2, vY));

        transform <----ERROR

Parse Error: Expected 'object or directive', transform found instead

What am I doing wrong?

Martin


Post a reply to this message

From: s1631001
Subject: Re: Connect 2 points with a box
Date: 29 Nov 2001 06:11:55
Message: <3C061811.915D5C49@namtar.qub.ac.uk>
Reorient_Trans() returns a transformation (like rotate, etc), which has
to be applied to an object(such as your box). Position your object with
your initial vectors, then call Reorient_Trans() inside the box{}
wrapper.

Martin Thoma wrote:
> 
> Hi Christoph,
> 
> thanx for your answer, but it doesn't work:
> 
>        #declare a1 = <0, 1, 0>;
>        #declare a2 = <xv3-xv1, yv3-yv1, zv3-zv1>;
> 
>         Reorient_Trans(a1, a2);
> 
> Gives me an Error in transforms.inc:
> 
> ...
> File: C:\Programme\POV-Ray for Windows v3.5\INCLUDE\transforms.inc  Line: 84
>         #local vZ2 = vnormalize(vcross(vX2, vY));
> 
>         transform <----ERROR
> 
> Parse Error: Expected 'object or directive', transform found instead
> 
> What am I doing wrong?
> 
> Martin

-- 
signature{
  "Grey Knight"
  contact{
    email "gre### [at] yahoocom"
  }
  site_of_week{
    url "http://mathworld.wolfram.com"
  }
}


Post a reply to this message

From: Dan Johnson
Subject: Re: Connect 2 points with a box
Date: 1 Dec 2001 04:11:11
Message: <3C089F45.E8D9542C@hotmail.com>
I know how to do that kind of thing.  I used a macro to create, and
position I_beams using an array of endpoints.  With a box you also have
to specify something like a down direction.  In my macro I used the
origin for this direction.  I think I may need to know a little more
about what you are trying to do with it, if I'm going to help you.  I
will probably have to adapt it a little.  I can send you a picture
demonstrating what I'm talking about.  

-- 
Dan Johnson 

http://www.geocities.com/zapob


Post a reply to this message

From: Dan Johnson
Subject: Re: Connect 2 points with a box
Date: 1 Dec 2001 04:31:17
Message: <3C08A3FB.E076BF2@hotmail.com>
Hmm just noticed that I have a macro called Box_connect...  I think I
will work on it tomorrow.  

-- 
Dan Johnson 

http://www.geocities.com/zapob


Post a reply to this message

From: Dan Johnson
Subject: Re: Connect 2 points with a box
Date: 2 Dec 2001 18:38:04
Message: <3C0ABBF1.C4D03497@hotmail.com>
Here is a mini scene that demonstrates my Box_connect macro.

#include "colors.inc"
#include "finish.inc"
light_source{ <-3,4,-5>*100 rgb 2}
camera{translate -4*z}

#macro Box_connect(Point1,Point2,Width,Height,Up,Gap)
      #local V1 = (Point2-Point1);
      #local Length = vlength(V1);
      #local X1 = vnormalize(z);                
      #local Z1 = vnormalize(vcross(X1,y));     
      #local Y1 = vcross(Z1,X1);                 
      #local X2 = vnormalize(V1);
      #local Z2 = vnormalize(vcross(X2,Up));
      #local Y2 = vcross(Z2,X2);
      box{<-Width/2,-Height/2,-Gap>,<Width/2,Height/2,Length+Gap> 
      
      transform {
      matrix <X1.x,Y1.x,Z1.x,X1.y,Y1.y,Z1.y,X1.z,Y1.z,Z1.z,0,0,0>
      matrix <vdot(X2,X1),vdot(X2,Y1),vdot(X2,Z1),vdot(Y2,X1),
      vdot(Y2,Y1),vdot(Y2,Z1),vdot(Z2,X1),vdot(Z2,Y1),vdot(Z2,Z1),0,0,0>
      matrix <X1.x,X1.y,X1.z,Y1.x,Y1.y,Y1.z,Z1.x,Z1.y,Z1.z,0,0,0> 
      translate Point1}
      
      }
#end

union{
object{Box_connect(x,y,.2,.1,y,0)}
object{Box_connect(-x,y,.2,.1,y,0)}
object{Box_connect(z,y,.2,.1,y,0)}
object{Box_connect(-z,y,.2,.1,y,0)}
object{Box_connect(x,-y,.2,.1,y,0)}
object{Box_connect(-x,-y,.2,.1,y,0)}
object{Box_connect(z,-y,.2,.1,y,0)}
object{Box_connect(-z,-y,.2,.1,y,0)}
object{Box_connect(z,-x,.1,.2,y,0)}
object{Box_connect(-z,-x,.1,.2,y,0)}
object{Box_connect(z,x,.1,.2,y,0)}
object{Box_connect(-z,x,.1,.2,y,0)}
pigment{Cyan}finish{Dull}}

union{
object{Box_connect(<1,1,1>,<1,-1,-1>,.2,.1,y,0)}
object{Box_connect(<1,1,1>,<-1,-1,1>,.2,.1,y,0)}
object{Box_connect(<1,1,1>,<-1,1,-1>,.1,.2,y,0)}
object{Box_connect(<-1,-1,1>,<1,-1,-1>,.1,.2,y,0)}
object{Box_connect(<-1,-1,1>,<-1,1,-1>,.2,.1,y,0)}
object{Box_connect(<-1,1,-1>,<1,-1,-1>,.2,.1,y,0)} // <--- try changing
the
pigment{Blue}finish{Dull}}                         //      last
parameter here
                                                   //      to learn what
Gap does
union{
object{Box_connect(<1,1,1>,<-1,1,1>,.1,.1,y,0)}
object{Box_connect(<1,-1,1>,<-1,-1,1>,.1,.1,y,0)}
object{Box_connect(<1,1,-1>,<-1,1,-1>,.1,.1,y,0)}
object{Box_connect(<1,-1,-1>,<-1,-1,-1>,.1,.1,y,0)}
object{Box_connect(<1,1,1>,<1,1,-1>,.1,.1,y,0)}
object{Box_connect(<-1,1,1>,<-1,1,-1>,.1,.1,y,0)}
object{Box_connect(<1,-1,1>,<1,-1,-1>,.1,.1,y,0)}
object{Box_connect(<-1,-1,1>,<-1,-1,-1>,.1,.1,y,0)}
object{Box_connect(<1,1,1>,<1,-1,1>,.1,.1,x,0)}
object{Box_connect(<-1,1,1>,<-1,-1,1>,.1,.1,x,0)}
object{Box_connect(<1,1,-1>,<1,-1,-1>,.1,.1,x,0)}
object{Box_connect(<-1,1,-1>,<-1,-1,-1>,.1,.1,x,0)}
pigment{Magenta}finish{Dull}}


-- 
Dan Johnson 

http://www.geocities.com/zapob


Post a reply to this message

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