POV-Ray : Newsgroups : povray.programming : 3D Trig Help for Bonehead needed Server Time
28 Jul 2024 16:25:07 EDT (-0400)
  3D Trig Help for Bonehead needed (Message 1 to 4 of 4)  
From: Rick Gutleber
Subject: 3D Trig Help for Bonehead needed
Date: 12 Sep 2000 12:07:23
Message: <39be54bb@news.povray.org>
I've got a simple question that's bugged me for years.  The answers got to
be simple, but I just can't figure it out.

I'm writing a C++ program to programmatically generate a Christmas tree and
I'm trying to put needles on the branches.  I have the start and end point
of the branch so I figured I would create the needles as if the branch
started at the origin and pointed straight up and then just translate and
rotate the union of the resulting needles so they actually appear on the
branch in the scene.  This translatation/rotation can occur in my C++ code
or the generated POV script, whichever is easier.

I've got an arbitary unit vector that reflects the orientation of the branch
(from VNormalize( ) in POV, or the good old Pythagorean distance function in
my C++ code), how do I turn that into an equivalent rotate < x, y, z >
statement so the needles end up on the branch?  I'm sure it's just the right
combination of atan( ) calls, but the details elude my addled brain.

Thanks for the help!

Rick
ric### [at] hiscom


Post a reply to this message

From: Jerry
Subject: Re: 3D Trig Help for Bonehead needed
Date: 13 Sep 2000 11:38:34
Message: <jerry-8875AC.08383513092000@news.povray.org>
In article <39be54bb@news.povray.org>, "Rick Gutleber" <ric### [at] hiscom> 
wrote:
>I've got an arbitary unit vector that reflects the orientation of the 
>branch (from VNormalize( ) in POV, or the good old Pythagorean 
>distance function in my C++ code), how do I turn that into an 
>equivalent rotate < x, y, z > statement so the needles end up on the 
>branch?  I'm sure it's just the right combination of atan( ) calls, 
>but the details elude my addled brain.

Honestly, it sounds like you're more advanced than I am so this probably 
won't help, but I have a page that talks about using trig functions in 
POV at http://www.hoboes.com/html/NetLife/POV/Trig/

Jerry


Post a reply to this message

From: Ken Cecka
Subject: Re: 3D Trig Help for Bonehead needed
Date: 13 Sep 2000 23:58:03
Message: <39C04B05.969385E2@alumni.washington.edu>
First let me rephrase your question:

You have a generic branch aimed in a particular direction.  You want to
automatically reorient it to match branches on your tree.  The actual
position of the branches doesn't really enter into the picture here
because that is just translation, so we can simplify the problem to
changing the orientation.  Now, lets say your generic branch starts at
the origin, and ends at the point <Ax,Ay,Az>.  And you want to re-orient
it so that it ends at <Bx,By,Bz>.  Lets refer to these points as
vectors, A and B, and make one more simplification, that A and B are the
same length.

If this sounds like it describes what you want to do, it's the same
question I asked several years back, and John VanSickle provided a great
solution using Pov's generic matrix transforms.  He describes it on his
web page on matrices at

http://users.erols.com/vansickl/matrix.htm
(scroll down to the section titled "Rotating from one vector to
another")

I never muddled through it enought to understand the math behind it, but
it worked great for me at the time.

Hope that helps (credit goes to John),

Ken

Rick Gutleber wrote:
> 
> I've got a simple question that's bugged me for years.  The answers got to
> be simple, but I just can't figure it out.
> 
> I'm writing a C++ program to programmatically generate a Christmas tree and
> I'm trying to put needles on the branches.  I have the start and end point
> of the branch so I figured I would create the needles as if the branch
> started at the origin and pointed straight up and then just translate and
> rotate the union of the resulting needles so they actually appear on the
> branch in the scene.  This translatation/rotation can occur in my C++ code
> or the generated POV script, whichever is easier.
> 
> I've got an arbitary unit vector that reflects the orientation of the branch
> (from VNormalize( ) in POV, or the good old Pythagorean distance function in
> my C++ code), how do I turn that into an equivalent rotate < x, y, z >
> statement so the needles end up on the branch?  I'm sure it's just the right
> combination of atan( ) calls, but the details elude my addled brain.
> 
> Thanks for the help!
> 
> Rick
> ric### [at] hiscom


Post a reply to this message

From: Rick Gutleber
Subject: Re: 3D Trig Help for Bonehead needed
Date: 21 Sep 2000 15:17:07
Message: <39ca5eb3$1@news.povray.org>
Thanks, I got the same info from another newsgroup and it worked great.

Here's the catch:  I've been using POV since version 0.5.  A long time ago I
started writing C/C++ programs to generate POV scripts and I still do.  The
fact of the matter is that what I used to need C/C++ for can now be done in
POV.  I should really just port my program to a POV script, but for now it's
just easier to keep doing what I'm doing.

Thanks,

Rick



"Ken Cecka" <cec### [at] alumniwashingtonedu> wrote in message
news:39C04B05.969385E2@alumni.washington.edu...
> First let me rephrase your question:
>
> You have a generic branch aimed in a particular direction.  You want to
> automatically reorient it to match branches on your tree.  The actual
> position of the branches doesn't really enter into the picture here
> because that is just translation, so we can simplify the problem to
> changing the orientation.  Now, lets say your generic branch starts at
> the origin, and ends at the point <Ax,Ay,Az>.  And you want to re-orient
> it so that it ends at <Bx,By,Bz>.  Lets refer to these points as
> vectors, A and B, and make one more simplification, that A and B are the
> same length.
>
> If this sounds like it describes what you want to do, it's the same
> question I asked several years back, and John VanSickle provided a great
> solution using Pov's generic matrix transforms.  He describes it on his
> web page on matrices at
>
> http://users.erols.com/vansickl/matrix.htm
> (scroll down to the section titled "Rotating from one vector to
> another")
>
> I never muddled through it enought to understand the math behind it, but
> it worked great for me at the time.
>
> Hope that helps (credit goes to John),
>
> Ken
>
> Rick Gutleber wrote:
> >
> > I've got a simple question that's bugged me for years.  The answers got
to
> > be simple, but I just can't figure it out.
> >
> > I'm writing a C++ program to programmatically generate a Christmas tree
and
> > I'm trying to put needles on the branches.  I have the start and end
point
> > of the branch so I figured I would create the needles as if the branch
> > started at the origin and pointed straight up and then just translate
and
> > rotate the union of the resulting needles so they actually appear on the
> > branch in the scene.  This translatation/rotation can occur in my C++
code
> > or the generated POV script, whichever is easier.
> >
> > I've got an arbitary unit vector that reflects the orientation of the
branch
> > (from VNormalize( ) in POV, or the good old Pythagorean distance
function in
> > my C++ code), how do I turn that into an equivalent rotate < x, y, z >
> > statement so the needles end up on the branch?  I'm sure it's just the
right
> > combination of atan( ) calls, but the details elude my addled brain.
> >
> > Thanks for the help!
> >
> > Rick
> > ric### [at] hiscom


Post a reply to this message

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