POV-Ray : Newsgroups : povray.advanced-users : Lightcycle trail Server Time
28 Jul 2024 16:16:30 EDT (-0400)
  Lightcycle trail (Message 1 to 2 of 2)  
From: Carl
Subject: Lightcycle trail
Date: 7 Jan 2005 21:25:00
Message: <web.41df437540afe8a2a54c62600@news.povray.org>
I have two questions I hope someone here can help me with.  I have a path
given by an array of vectors.  For example:

#declare path1_num = 5;       //number of points used to define spline
                                (one more then the number of segments)

#declare path1 = array[path1_num][3]
{
  {<0,0,0>,<0,0,1>,<0,1,0>},        //first point of spline,
                                    //forward for first segment of spline,
                                    //up for first segment of spline
  {<0,0,10>,<1,0,0>,<0,1,0>},       //second point of spline,
                                    //forward for second segment of spline,
                                    //up for second segment of spline
  {<20,0,10>,<0,0,1>,<0,1,0>},      //third point of spline,
                                    //forward for third segment of spline,
                                    //up for third segment of spline
  {<20,0,40>,<-1,0,0>,<0,1,0>},     //forth point of spline,
                                    //forward for last segment of spline,
                                    //up for last segment of spline
  {<10,0,40>,<-1,0,0>,<0,1,0>}      //last point of spline,
                                    //forward at end of spline,
                                    //up at end of spline
};

First question, assume the path is confined to the y=0 plane as above with
90 degree turns.  I want a prism that will draw that path with some width.
For example, for the above path that prism could be:

#declare path1_sides = prism {
  linear_sweep
  linear_spline
    0,   // sweep the following shape from here ...
    2,   // ... up through here
    11,  // the number of points making up the shape ...
    <0.1,0>,
    <0.1,9.9>,
    <20.1,9.9>,
    <20.1,40.1>,
    <10.0,40.1>,
    <10.0,39.9>,
    <19.9,39.9>,
    <19.9,10.1>,
    <-0.1,10.1>,
    <-0.1,0>
    <0.1,0>
}

Now given a general array/path like the above I think it should be possible
to write a macro that will generate the prism, however its proving to be
alot harder then I think it should be.  Anyone here got an idea or some
simple code that will do the above?

Second question... let's relax the requirement that the path be in the y=0
plane.  Take this path for example:

#declare path1 = array[path1_num][3]
{
  {<0,0,0>,<0,0,1>,<0,1,0>},  //first point of spline,
                              //forward for first segment of spline,
                              //up for first segment of spline
  {<0,0,1>,<1,0,0>,<0,1,0>},  //second point of spline,
                              //forward for second segment of spline,
                              //up for second segment of spline
  {<2,0,1>,<0,1,0>,<-1,0,0>}, //third point of spline,
                              //forward for third segment of spline,
                              //up for third segment of spline
  {<2,3,1>,<0,0,1>,<-1,0,0>}, //forth point of spline,
                              //forward for last segment of spline,
                              //up for last segment of spline
  {<2,3,5>,<0,0,1>,<-1,0,0>}  //last point of spline,
                              //forward at end of spline,
                              //up at end of spline
};

Now assume the above array just contained the vectors defining the points of
the spline.  I know the difference in two consecutive points can be used to
define a "forward" for any segment of the spline, but is there an easy way
to know what the "up" vector should be for a given segment given the
initial "up".  Again assume just 90 degree turns.  Left and Right turns
don't change the "up" vector.  For Down turns or dives, the "up" vector
becomes the "forward" vector of the previous segmant.  For Up turns or
climbs, the "up" vector becomes the negative of the "forward" vector of the
previous segmant.  So in short I'm trying to create a macro which will
create the above array given:
  1.  The number of points used to define the path.  Call it "x".
  2.  The 1D array of those points call it path[x].
  3.  The initial "up" vector.  Call it up[1].
All the "forward" and the remainder if the "up" vectors should follow from
the above.

Thanks,
Carl


Post a reply to this message

From: Mike Williams
Subject: Re: Lightcycle trail
Date: 8 Jan 2005 00:51:08
Message: <SQSn7JAqR33BFwVl@econym.demon.co.uk>
Wasn't it Carl who wrote:
>Now given a general array/path like the above I think it should be possible
>to write a macro that will generate the prism, however its proving to be
>alot harder then I think it should be.  Anyone here got an idea or some
>simple code that will do the above?

You might try using the SweepSpline.inc macro.

There's an example in my isosurface tutorial. (It doesn't use
isosurfaces, but it does something similar to what you can achieve with
isosurfaces that use spline functions.) The source, and Ingo's
makemesh.inc which it requires, can be downloaded from the bottom of the
page. <http://www.econym.demon.co.uk/isotut/more.htm>

In this case you'd set
Track   to be a linear spline describing the path of the lightcycle
Shape   to be a linear spline describing the prism cross section
Waist   to be a linear spline that returns a constant value

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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