POV-Ray : Newsgroups : povray.general : How would I do this? Server Time
6 Nov 2024 20:19:56 EST (-0500)
  How would I do this? (Message 1 to 8 of 8)  
From: Tyler Eaves
Subject: How would I do this?
Date: 23 Mar 2004 21:27:01
Message: <pan.2004.03.24.02.28.58.85161@NOSPAMml1.net>
Okay, I've got a vector math question for those of you who are good with
that kinda stuff.....

Here's the setup. Imagine a spline describing a 3D curve with undulations,
rather like, say, a roller coaster track. (Indeed, that is exactly what I
intend to do with it.) I want to be able to translate a point relative to
the origin 'along' the spline, so that basically the Z-axis at the origin
would point along the tangent of the spine at the point. Now the tricky
part. I want to *twist* the spline, with a another 1d spline that
represents the twist in degrees at any given point.


Post a reply to this message

From: Hughes, B 
Subject: Re: How would I do this?
Date: 23 Mar 2004 22:07:57
Message: <4060fb8d$1@news.povray.org>
"Tyler Eaves" <tyl### [at] NOSPAMml1net> wrote in message
news:pan### [at] NOSPAMml1net...
>
> Here's the setup. Imagine a spline describing a 3D curve with undulations,
> rather like, say, a roller coaster track. (Indeed, that is exactly what I
> intend to do with it.) I want to be able to translate a point relative to
> the origin 'along' the spline, so that basically the Z-axis at the origin
> would point along the tangent of the spine at the point. Now the tricky
> part. I want to *twist* the spline, with a another 1d spline that
> represents the twist in degrees at any given point.

I'm not sure if you'd need anything more than the already included sample in
scenes/animations/splinefollow. It does just what you're asking about,
except maybe the part about using a spline for the twisting action.
Although, it does tilt according to the path curvature. Uses a spline you
create to figure the transformations along it.

Have a look at the transforms.inc, Spline_Trans() macro.

-- 
Bob H.
http://www.3digitaleyes.com


Post a reply to this message

From: Tyler Eaves
Subject: Re: How would I do this?
Date: 23 Mar 2004 22:09:26
Message: <pan.2004.03.24.03.11.23.650260@NOSPAMml1.net>
On Tue, 23 Mar 2004 21:07:51 -0600, Hughes, B. wrote:


> 
> Have a look at the transforms.inc, Spline_Trans() macro.

I should have mentioned that...

I tried that in the past, and found it very lacking performance wise. I'm
going to be building a *lot* of geometry along this spline...


Post a reply to this message

From: Warp
Subject: Re: How would I do this?
Date: 24 Mar 2004 05:35:32
Message: <40616474@news.povray.org>
Tyler Eaves <tyl### [at] nospamml1net> wrote:
> > Have a look at the transforms.inc, Spline_Trans() macro.

> I tried that in the past, and found it very lacking performance wise. I'm
> going to be building a *lot* of geometry along this spline...

  You can gain some performance by copying the macro in question (and
if it uses any other macro, those too) to your scene file. This is due
to how the SDL parser works.
  Of course it still isn't as fast as it could be, but something is
better than nothing.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Tyler Eaves
Subject: Re: How would I do this?
Date: 24 Mar 2004 10:10:54
Message: <pan.2004.03.24.15.12.50.425564@NOSPAMml1.net>
On Tue, 23 Mar 2004 21:28:58 -0500, Tyler Eaves wrote:

> Okay, I've got a vector math question for those of you who are good with
> that kinda stuff.....
> 
> Here's the setup. Imagine a spline describing a 3D curve with undulations,
> rather like, say, a roller coaster track. (Indeed, that is exactly what I
> intend to do with it.) I want to be able to translate a point relative to
> the origin 'along' the spline, so that basically the Z-axis at the origin
> would point along the tangent of the spine at the point. Now the tricky
> part. I want to *twist* the spline, with a another 1d spline that
> represents the twist in degrees at any given point.

Well, with some various ideas, I've worked out a way to handle it without
using Spline_Trans. Still not as fast as I'd like, but it works, kinda.
Except that if the track comes back along the -z axis, the banking goes
crazy.

180 turn - problems: http://tylere.com/coaster1.png
90 turn - no problems: http://tylere.com/coaster2.png
270 turn - problem at the 180o point: http://tylere.com/coaster3.png


Here's the code I've hacked up:

#include "transforms.inc"
camera{location <100,60,-100> look_at <100,0,50>}
light_source{<0,200,-400>,1}
plane{y,-25 pigment{rgb <0,1,0>}}
#declare track = spline{
  natural_spline
  -1, <0,60,-1>
  0, <0,60,0>
  100, <0,60,100>
  200, <50,20,150>
  300, <100,5,100>
  400, <100,5,-50>
}
#declare banking = spline{
  linear_spline
  0,0
  100,0
  200,-60
  300,-70
 


  400, 0
}
#declare p = -1;
#declare last = transform{rotate <0,0,banking(p).x>
Reorient_Trans(<0,0,1>,vnormalize(track(p+.5)-track(p))) translate track(p)};
#declare s = 0;
#declare p = 0;
#while (p < 400)
  #declare vec = vnormalize((track(p+.5)+<0,.01,0>)-track(p)); 
   #declare trans = transform{rotate <0,0,banking(p).x>
Reorient_Trans(<0,0,1>,vnormalize((track(p+.5)+<0,.01,0>)-track(p))) translate
track(p)};
  union{
  cylinder{vtransform(<-2,-4,0>,trans),vtransform(<-2,-4,0>,last),.25}
  cylinder{vtransform(<2,-4,0>,trans),vtransform(<2,-4,0>,last),.25}
  cylinder{vtransform(<-2,-4,0>,trans),vtransform(<2,-4,0>,trans),.2}
  pigment{rgb <0,0,1>}
  }
  #declare s = s + 1;
  #if (s > 10)
    #declare s = 0;
    cylinder{vtransform(<0,-8,0>,trans),
vtransform(<0,-8,0>,trans)-<0,vtransform(<0,-8,0>,trans).y + 25,0>,.5 pigment{rgb 1}}
    cone{vtransform(<0,-8,0>,trans),.5, vtransform(<0,-4,0>,trans),.2 pigment{rgb
<0,0,1>}}
  #end
  #debug concat(str(p,0,0)," - ",str(banking(p).x,0,2),"\n")
  #debug concat(str(vec.x,0,1),",",str(vec.y,0,1),",",str(vec.z,0,1),"\n")  
  #declare last = trans;
  #declare p = p + 3;
#end


Post a reply to this message

From: Tyler Eaves
Subject: Re: How would I do this?
Date: 24 Mar 2004 12:11:06
Message: <pan.2004.03.24.17.13.04.807580@NOSPAMml1.net>
On Wed, 24 Mar 2004 10:12:52 -0500, Tyler Eaves wrote:

Here's another shot. 
http://tylere.com/coaster4.png

Shot from directly above the 'singularity', with an ortho camera. The red
line represents the actual spline.


Post a reply to this message

From: stephen parkinson
Subject: Re: How would I do this?
Date: 24 Mar 2004 14:46:32
Message: <4061e598$1@news.povray.org>
Tyler Eaves wrote:
> On Wed, 24 Mar 2004 10:12:52 -0500, Tyler Eaves wrote:
> 
> Here's another shot. 
> http://tylere.com/coaster4.png
> 
> Shot from directly above the 'singularity', with an ortho camera. The red
> line represents the actual spline.

that looks suspiciously like a divide by 'something getting very small'

limiting to the vicinity of the defect...
would it be possible to put an extended pointing cylinder starting at 
each point in spline pointing in the vector direction of the rails?
also output the angle between the vector and each axis?
perhaps look at the source/internal doc on the transform function for 
indications of special cases?

stephen


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: How would I do this?
Date: 24 Mar 2004 15:02:14
Message: <4061e946$1@news.povray.org>
> Here's the setup. Imagine a spline describing a 3D curve with undulations,
> rather like, say, a roller coaster track. (Indeed, that is exactly what I
> intend to do with it.) I want to be able to translate a point relative to
> the origin 'along' the spline, so that basically the Z-axis at the origin
> would point along the tangent of the spine at the point. Now the tricky
> part. I want to *twist* the spline, with a another 1d spline that
> represents the twist in degrees at any given point.

Judging from the image and the other posts in this thread, you're having a
simliar problem like I had with my original tunnel-concept. When you just
want to calculate an outward vector at a given position, a straight forward
approach can introduce jumps in the calculations. In my case, the rotation
would jump back and forth for the right axis when the outward vector would
point towards a certain direction.

What I did (after Rune mentioned it) was to adjust the outward vector
progressively. You'll be running from one end to the other anyway, so
there's no loss in doing that. Then, all you need to do is judge by the
change in the heading from one interval to the next, how to affect the
outward vector.

Another approach would be, if you're using two splines anyways, why not make
one spline the path, and the other the up- or down-path? The rails' bottom
could always point towards a point on the other spline, and your problems
are solved. If you then want to introduce twists, just begin at a certain
point on the spline to rotate the objects/nodes/whatever about their axis
until you've come back to either 0 or 360 degrees, after which the twist
ends.

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Email: tim.nikias (@) nolights.de


Post a reply to this message

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