POV-Ray : Newsgroups : povray.binaries.images : Rail segments assembly problem : Re: Rail segments assembly problem Server Time
5 Nov 2024 13:26:01 EST (-0500)
  Re: Rail segments assembly problem  
From: Martin
Date: 12 Apr 2009 07:00:17
Message: <49e1c9c1$1@news.povray.org>

> High!
> 
> Another raytracing and video editing weekend with my loved one... I 
> started a medium-sized project dealing with an automatic commuter maglev 
> train system (to be later on implemented in some futuristic city), first 
> the rail segments, for which I programmed two macros (see code on 
> p.b.s-f.).
> 
> These macros (StraightRail() and BendRail()) are invoked according to 
> data read in from an ASCII text file (attached here) and stored in a 
> two-dimensional array. The format of the data is as follows:
> 
> 1. Segment type (0 for "straight", 1 for "bend")
> 2. Length (if straight)/Arc angle (if bend)
> 3. Radius (bend only; third value is not read for straight segments)
> 
> This array is processed line by line, and the subsequent rail segments 
> are translated and rotated to fit together. All worked well - unless I 
> added a bend segment curving "southward". The following straight segment 
> was placed out of way, as you can see on the attached image.
> 
> It seems to be a problem with the z dimension, as the x value is correct...
> 
> See you in Khyberspace!
> 
> Yadgar
> 
> ------------------------------------------------------------------------
> 
Hello

You are not taking into account the bended sector rotation

     #case (1)
       object
       {
         BendRail(RailElements[i][2], RailElements[i][1])
         rotate y*d //<- watch this!
         translate trans
         #if (RailElements[i][1] >= 0 )//& d+RailElements[i][1] < 90)
           #declare diff = 0.3;
         #else
           #declare diff = -0.3;
         #end
         #declare dir= select(RailElements[i][1],1,-1,-1);
         #declare pt= vrotate(x*(RailElements[i][2]+diff)*dir,
                          RailElements[i][1]*y)-x*RailElements[i][2]*dir;
         #declare trans= trans+vrotate(pt,y*d); //<-- solved
         #declare d = d+RailElements[i][1];
         #warning concat("< ",str(trans.x, 3, 3), ", ", str(trans.y, 3, 
3), ", ", str(trans.z, 3, 3), " >")
       }
     #break

See you.


Post a reply to this message

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