POV-Ray : Newsgroups : povray.advanced-users : Align box to splines Server Time
25 Nov 2024 14:36:19 EST (-0500)
  Align box to splines (Message 1 to 7 of 7)  
From: Greg M  Johnson
Subject: Align box to splines
Date: 24 Sep 2002 13:06:30
Message: <3d909b96$1@news.povray.org>
I have two splines where
  vlength(Spline_1(Val)-Spline_2(Val)= W
for every value of Val.

Now I have a box with one dimenstion W and a given L (H is irrelevant).

Q: How do I get the four corners of W&L to be aligned as closely as possible
to the two curves?

The application is a railroad with not-so-flat rails (ala'
http://news.povray.org/povray.binaries.images/27516/).   I can think of a
very, very hairy algorithm that involves millions of rotations until I get
it best aligned in three axes, but I'm wondering if there were a more simple
trick out there....


Post a reply to this message

From: Peter Popov
Subject: Re: Align box to splines
Date: 25 Sep 2002 01:48:26
Message: <l3j2pu02gocibkq3jkd9ngrtef5q4fu27o@4ax.com>
On Tue, 24 Sep 2002 13:06:16 -0400, "Greg M. Johnson"
<gregj:-)565### [at] aolcom> wrote:

>Q: How do I get the four corners of W&L to be aligned as closely as possible
>to the two curves?

You can fit them on the splines with a matrix, assuming that not only
the distance between the splines is constant, but the vector itself
(i.e. if you get rid of the vlength() in your definition, it should
still yield a constant value)

There was a macro that transforms one triangle into another - I just
can't tell you the name of the macro itself. If you define the
original triangle from the first three of the four bottommost corners
of your box, and the new triangle as follows,

triangle { S1=Spline_1(Val), S2=Spline_2(Val), S3=Spline_2(Val+L) }

then that macro will move and shear your box into position.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Le Forgeron
Subject: Re: Align box to splines
Date: 25 Sep 2002 05:40:31
Message: <3D91849B.6030702@free.fr>
Greg M. Johnson wrote:

> I have two splines where
>   vlength(Spline_1(Val)-Spline_2(Val)= W
> for every value of Val.
> 
> Now I have a box with one dimenstion W and a given L (H is irrelevant).
> 
> Q: How do I get the four corners of W&L to be aligned as closely as possible
> to the two curves?


First, position the center of the box :
#local center = (Spline_1(Val)+Spline_2(Val))/2;
Next find the orientation of the box:
#local orienta = Spline_1(Val) - center; /* length of orienta is W/2 */

Then use the Reorient_Trans(x,orienta) macro from transforms.inc
(you might want to replace x with either y or z, according to your box)
just like that:

box { -W/2,W/2 /* any texture&interior goes here */
Reorient_Trans(x,orienta)
translate center }



> 
> The application is a railroad with not-so-flat rails (ala'
> http://news.povray.org/povray.binaries.images/27516/).   I can think of a
> very, very hairy algorithm that involves millions of rotations until I get
> it best aligned in three axes, but I'm wondering if there were a more simple
> trick out there....
> 
> 
>


Post a reply to this message

From: Alf Peake
Subject: Re: Align box to splines
Date: 25 Sep 2002 11:06:53
Message: <3d91d10d@news.povray.org>
My maths isn't up to answering your question, but I was wondering how
you would deal with the track sections that may be twisted, that is,
the ties do not remain horizontal. I guess you could allow the wheel's
suspension to solve that one. You would only need to consider the
center line, parallel to the track, of the box base then?

Alf


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Align box to splines
Date: 25 Sep 2002 22:35:05
Message: <3d927259$1@news.povray.org>
I'm sorry that this explanation is likely over my head and possibly not
exactly applicable to my situation.   At least one problem is in the
difficulty of finding even a THIRD point without some stepwise creeping
along Val.

"Peter Popov" <pet### [at] vipbg> wrote in message
news:l3j2pu02gocibkq3jkd9ngrtef5q4fu27o@4ax.com...
> You can fit them on the splines with a matrix, assuming that not only
> the distance between the splines is constant, but the vector itself
> (i.e. if you get rid of the vlength() in your definition, it should
> still yield a constant value)


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Align box to splines
Date: 25 Sep 2002 22:36:26
Message: <3d9272aa$1@news.povray.org>
I think I'll just rotate along the direction of motion to get an "average"
fit.  May not work really close up on really rought terrain, but at least
it'll make some accomodation for roughness.

"Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
news:3d91d10d@news.povray.org...
> My maths isn't up to answering your question, but I was wondering how
> you would deal with the track sections that may be twisted, that is,
> the ties do not remain horizontal. I guess you could allow the wheel's
> suspension to solve that one. You would only need to consider the
> center line, parallel to the track, of the box base then?
>
> Alf
>
>
>


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Align box to splines
Date: 25 Sep 2002 22:44:22
Message: <3d927486@news.povray.org>
I guess I "already knew" how to do this, but the wisdom is that this is the
best thing for at least the engine.  I can use the Spline itself to
calculate a vector which will account for the reorientation in y & the
direction of travel.

 But for the second car, I have to be a little bit more meticulous, because
I have to choose a Val for it that allows it to be coupled with the
engine...


"Le Forgeron" <jgr### [at] freefr> wrote in message
news:3D9### [at] freefr...
> Greg M. Johnson wrote:
>
> > I have two splines where
> >   vlength(Spline_1(Val)-Spline_2(Val)= W
> > for every value of Val.
> >
> > Now I have a box with one dimenstion W and a given L (H is irrelevant).
> >
> > Q: How do I get the four corners of W&L to be aligned as closely as
possible
> > to the two curves?
>
>
> First, position the center of the box :
> #local center = (Spline_1(Val)+Spline_2(Val))/2;
> Next find the orientation of the box:
> #local orienta = Spline_1(Val) - center; /* length of orienta is W/2 */
>
> Then use the Reorient_Trans(x,orienta) macro from transforms.inc
> (you might want to replace x with either y or z, according to your box)
> just like that:
>
> box { -W/2,W/2 /* any texture&interior goes here */
> Reorient_Trans(x,orienta)
> translate center }
>

>
> >
> > The application is a railroad with not-so-flat rails (ala'
> > http://news.povray.org/povray.binaries.images/27516/).   I can think of
a
> > very, very hairy algorithm that involves millions of rotations until I
get
> > it best aligned in three axes, but I'm wondering if there were a more
simple
> > trick out there....
> >
> >
> >
>
>


Post a reply to this message

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