POV-Ray : Newsgroups : povray.binaries.images : Rail segments assembly problem Server Time
31 Jul 2024 18:27:11 EDT (-0400)
  Rail segments assembly problem (Message 1 to 6 of 6)  
From: Jörg 'Yadgar' Bleimann
Subject: Rail segments assembly problem
Date: 11 Apr 2009 10:37:12
Message: <49e0ab18@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


Post a reply to this message


Attachments:
Download 'cabinrailway.png' (11 KB) Download 'railtest.txt' (1 KB)

Preview of image 'cabinrailway.png'
cabinrailway.png

From: Martin
Subject: Re: Rail segments assembly problem
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

From: Jörg 'Yadgar' Bleimann
Subject: Re: Rail segments assembly problem
Date: 12 Apr 2009 09:55:48
Message: <49e1f2e4$1@news.povray.org>
High!

Martin wrote:

> You are not taking into account the bended sector rotation

>         #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

 From 400 metres above, your code looks like a solution... but then I 
started animating a camera ride along the rail, and when I came to the 
end of the first curved section, I got the result attached here...

I just can't figure out the reason... I tried several values for "diff", 
the closest I found was 0.09 (and -0.09 respectively for left bends), 
but even then only the end of the right bend roughly fits together with 
the second straight section, not the end of the second curved (left 
bend) section visible to the left of the image... I'm totally clueless!

See you in Khyberspace!

Yadgar


Post a reply to this message


Attachments:
Download 'cabinrailway_0001.jpg' (9 KB)

Preview of image 'cabinrailway_0001.jpg'
cabinrailway_0001.jpg


 

From: Martin
Subject: Re: Rail segments assembly problem
Date: 12 Apr 2009 13:16:34
Message: <49e221f2$1@news.povray.org>

> High!
> 
> Martin wrote:
> 
>> You are not taking into account the bended sector rotation
> 
>>         #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
> 
>  From 400 metres above, your code looks like a solution... but then I 
> started animating a camera ride along the rail, and when I came to the 
> end of the first curved section, I got the result attached here...
> 
> I just can't figure out the reason... I tried several values for "diff", 
> the closest I found was 0.09 (and -0.09 respectively for left bends), 
> but even then only the end of the right bend roughly fits together with 
> the second straight section, not the end of the second curved (left 
> bend) section visible to the left of the image... I'm totally clueless!
> 
> See you in Khyberspace!
> 
> Yadgar
> 
> ------------------------------------------------------------------------
> 
  Ah, so there are another design problem. The StrightRail() object is 
not centered , and that's what you're seeign. I propose you to center it:

#macro StraightRail(le) // le: length in meters
   [...]
     object { StraightOuterRounding }
     object { StraightOuterRounding translate x*0.59 }
     texture { T_Bright_Metal } translate -0.3*x //<---- center it
   }
#end

Then the BendRail don't need to be off-centre:
#macro BendRail(rd, ang)
    [...]
     object { BendOuterRounding translate y*0.495 }
     object { BendInnerRounding translate y*0.495 }
     texture { T_Bright_Metal } #if(!RevEng)
     #if (ang >= 0)
       translate x*rd //<--------- also centered
     #else
       translate -x*rd
     #end #end
   }
#end

And now there is no need to compute this movement

[...]
     #case (1)
       object
       {
         BendRail(RailElements[i][2], RailElements[i][1])
         rotate y*d
         translate trans
        /*
         #if (RailElements[i][1] >= 0 )
           #declare diff = 0.3;
         #else
           #declare diff = -0.3;
         #end
        */ //<-- simply eliminate this term from the equations.
  [...]
     #break
   #end

cheers.


Post a reply to this message


Attachments:
Download 'rail.jpg' (7 KB)

Preview of image 'rail.jpg'
rail.jpg


 

From: Jörg 'Yadgar' Bleimann
Subject: Re: Rail segments assembly problem
Date: 12 Apr 2009 16:03:49
Message: <49e24925$1@news.povray.org>
High!

Martin schrieb:

>  Ah, so there are another design problem. The StrightRail() object is 
> not centered , and that's what you're seeign. I propose you to center it:
> 
> #macro StraightRail(le) // le: length in meters
>   [...]
>     object { StraightOuterRounding }
>     object { StraightOuterRounding translate x*0.59 }
>     texture { T_Bright_Metal } translate -0.3*x //<---- center it
>   }
> #end
> 
> Then the BendRail don't need to be off-centre:
> #macro BendRail(rd, ang)
>    [...]
>     object { BendOuterRounding translate y*0.495 }
>     object { BendInnerRounding translate y*0.495 }
>     texture { T_Bright_Metal } #if(!RevEng)
>     #if (ang >= 0)
>       translate x*rd //<--------- also centered
>     #else
>       translate -x*rd
>     #end #end
>   }
> #end
> 
> And now there is no need to compute this movement
> 
> [...]
>     #case (1)
>       object
>       {
>         BendRail(RailElements[i][2], RailElements[i][1])
>         rotate y*d
>         translate trans
>        /*
>         #if (RailElements[i][1] >= 0 )
>           #declare diff = 0.3;
>         #else
>           #declare diff = -0.3;
>         #end
>        */ //<-- simply eliminate this term from the equations.
>  [...]
>     #break
>   #end

Works great!
Muchas gracias, Martin!
Prepare to find your name in the city of Port Whatmough one day... or on 
any other moon or planet in that stellar system!

See you in Khyberspace - www.khyberspace.de !

Yadgar


Post a reply to this message

From: Martin
Subject: Re: Rail segments assembly problem
Date: 13 Apr 2009 05:24:03
Message: <49e304b3$1@news.povray.org>

> 
> Works great!
> Muchas gracias, Martin!

De nada :)

> Prepare to find your name in the city of Port Whatmough one day... or on 
> any other moon or planet in that stellar system!
 >
> See you in Khyberspace - www.khyberspace.de !
> 
> Yadgar

XD. Thank you! Now I can brag of having something with my name.


Post a reply to this message

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