News:

Due to heavy spamming attempts on this forum, automatic registration has been disabled. We will approve registration requests as quickly as possible (unless you're a spammer of course :) )

Main Menu

Easement shape issue

Started by Maletrain, March 21, 2017, 02:52:11 PM

Previous topic - Next topic

Maletrain

First, I need to tell you that I have been using AnyRail for over a year, but have just joined the forum.  I have become pretty adept at using the features, and have read most of the previous forum posts related to this issue concerning easements
I have been designing track plans and using the "easement flex" tool quite a bit.  Easement lengths and offsets are an important consideration when trying to see if a track plan will fit a restricted space
But, when trying to move from planning to building, I discovered that the AnyRail version of an easement is shorter than what is produced by the tools commonly used in the United States to set-up easements for real and model railroads.
As background, "Model Railroader" magazine published an article in its October, 1969 issue that described how to use "cubic spirals" to lay-out easements from straight to curved tack of specified radii as well as between two curves of different radii.  And, it provided templates for doing so, as well as the mathematics for making other templates.  The parent company of that magazine, Kalmbach Publishing, also publishes a book titled "Track Planning for Realistic Operation" that shows how to use a flexible batten to draw centerlines for similar easements when laying out a tack plan on your baseboard.
In both cases, the parameters used are the length of the spiral section and the radius of the curve to which it connects.  The recommendation in the cubic spiral article was to use the template that provides at least the length of your longest car or engine between the tangent point and the point on the template for the minimum radius to be used by that car on your layout.   The batten method in the book uses an even larger length.
So, I am concerned that the "easement flex" pieces created by AnyRail are too short for my purpose.  They seem to be starting the curve more abruptly than the cubic spiral when drawn to the same net diverging angle, or going through a larger angle when drawn to the same length as the cubic spiral.  Either way, the AnyRail easement will create more car-to-car coupler misalignment for the same length easement  provided by a cubic spiral configuration.
I have developed a method to make a "virtual jig" with AnyRail that allows me to make an easement in the configuration of the cubic spiral templates.  I can describe that here if there is interest from other members.
I have also looked at the mathematics of the cubic spiral, and, just recently, the Bezier curves used by AnyRail to draw easements and other shapes with flex track.  Both use cubic equations, and the cubic spiral seems to be a special case of the more general Bezier curve equation.  Although I have not studied Bezier curves enough to see how to use mathematics to set their control points to create the cubic spiral easement shape, I suspect that David could see how to do it once I describe the (very convenient) mathematical  attributes of the cubic spiral easements.  If there is interest in doing that, I can provide the mathematical discussion here for cubic spiral calculations.
But, this post is already too long.  So, I will wait to see where other members' interests are before going into more details.

David

For the flex track easements, AnyRail uses the theory described in:

Constrained Guided Spiral Transition Curves by Zulfiqar Habib and Manabu Sakai

You should be able to find the article on line.

The easement should be such that it can be described by a Bézier curve, as that is how flex track is defined internally.
David Hoogvorst. Founder and Owner of DRail Software. Creator of AnyRail.

Maletrain

#2
I retrieved the paper you mentioned and read it.  Unfortunately, it uses an approach that is much more complex than what I have for the "cubic spiral" and MAY use some different definitions for things like the "length" of the spiral. 

My mathematics is based on a simple relationships between the x and y coordinates of the easement line and offsets for things like the distance of the circle's center from the extension of the straight line that connects the circle to the easement.  The paper uses another parameter, t, as the independent variable and defines x and y by defining their first derivatives as quadratic functions of t.  Translating between these two approaches is the problem we need to overcome to see why our two methods produce differently shaped easement curves.

The easement curves I use, assuming it starts from a straight line that is the x axis in Cartesian (rectangular) coordinates, is simply in the form of y= (x^3)/(6 C)  where C is a constant for any particular easement.  This curve has the useful characteristic that the product of the x value and the radius of the curve that is tangent to the easement for that x value equals the constant, C.  The angle of the easement curve relative to the x axis for any radius is arcsin[C/(2 r^2)], which is also arcsin[(x^2)/2C].  There are more relationships that I can provide.  I did not derive them; I just use what was in the article and some simple algebra and trigonometry to manipulate them.

Are you familiar enough with the Bezier curve equations to put the curve in that article into the Bezier form?

David

In the paper, the Bézier points are defined in Lemma 2.1. I did not work them out myself.
David Hoogvorst. Founder and Owner of DRail Software. Creator of AnyRail.

Maletrain

I must not have found the same paper you are using, because there is no Lemma 2.1 in any papers that came up in my Google search on "Constrained Guided Spiral Transition Curves by Zulfiqar Habib and Manabu Sakai".  I did find several of their papers, though.

Can you please provide me with a link to the paper you are using, so we are looking at the same thing?

David

It's here:
www.kurims.kyoto-u.ac.jp/~kyodo/kokyuroku/contents/pdf/1395-25.pdf
David Hoogvorst. Founder and Owner of DRail Software. Creator of AnyRail.

Maletrain

#6
OK, I retrieved the paper and read it.  Unfortunately, it assumes I already know a lot about Bezier curves, which I do not, and it does not provide much in the way of pictorial representation of the geometric relationships between the lines and the 2 shape control points.  So, it would be a long time before I will have enough free time to learn Bezier curves and fit one to the simple cubic curve used in the Model Railroader article.

Are you able to make a Bezier curve fit the simple y = (x^3)/(6 C) equation with the value of C supplied as the input variable by a user? (Or, C could be computed as the length of the curve times the radius it connects to, which is what the user needs to consider to compute C as the product of those two values.

Maletrain

Rather than try to use the Bezier curve math, I started comparing the eaasements that AnyRail draws to the cubic curves I use and to the circular radius that we are connecting to. 

I have come to the conclusion that the AnyRail easements and the control points (as now implemented in AR) for a piece of flex track will not create a "cubic spiral".  As I increase the angle parameter for the AR easements, they seem to go to the specified radius and then stay at that radius for rather long stretches.  The cubic spiral will slowly increase the radius over the entire easement length until it just touches the circular curve at the specified radius.

When I try to use control points to make a piece of flex fit a cubic spiral, I cannot make that fit.  The control points seem to make the flex bend most in the middle of the section, while the cubic spiral is most bent at the end that attaches to the circular section.  I was hoping that attaching a piece of sectional track of the desired radius to the end of the flex would help, but the control points behave the same as when the flex is attached to a straight piece of sectional track.

So, unless David decides to provide a feature to produce cubic spiral easements, I will have to continue to use my "virtual jig" to make them to my specifications and then copy and paste them where I need them.

At least the actual spiral shape is not necessary for planning a layout.  So long as I properly calculate the angle of deflection and the offset for the easement length and curve radius I want, the "jig" gives me two ends to the flex track section that are in the same places and angles as the ends to a cubic spiral, so a real cubic spiral will fit the same way when I build the layout.  The only down-side is that I cannot print the actual easement shape full scale to use as a template to actually lay track, because I cannot get AnyRail to make the cubic spiral shape.  But, that is an easy shape to plot out on the layout (which is why real railroads used it).

Maletrain

Found an error in my math.

The "cubic spiral" curve is y = (x^3)/(6 C) the way I defined the constant "C".  (I had a factor of 2 error that was compounded by the cube but divided into the cube, leaving a factor of 4 error.)

This time, "modify" did work on my posts, so I have corrected the error in my previous 2 posts.  This post is to let people who may be trying to work-out this math know that the change was made.

Sorry if this has caused problems for anybody.

Maletrain

#9
David, I seem to be talking to myself in this post.  Would you be so kind as to explain how your program choses a length for an easment, given user inputs for the radius to be connected with and the angle that the easement should make?

I have looked at the paper you suggested, and it seems to only show that the Bezier curve makes a "fair" connection to the radius at one end and the straight section at the other end.  It does not seem to say anything about the nature of the curve between with respect to the actual mechanical function of an easement.

Because you are using cubic equations for the Bezier curves, it is possible to make that curve match a "cubic spiral" easement, but the AnyRail easements do not match a cubic spiral.

And, a cubic spiral is only an approximation of the more desireable Euler spiral, which linearly increases the centrifugal force up to the point where it becomes constant at the constant radius circle.  AnyRail easements are not Euler spirals, either.

Once I found the issue with the "cubic spiral" getting into an area where it no longer fits some assumptions about matching the Euler spiral, I was able to use Bezier curves to match the "cubic spiral" over the useful range of diverging angles.  But, that is a small range.  A cubic spiral is not really a spiral at all, and actually starts increasing in radius after 25 degrees of deflection from the straight path.  More importantly, the "cubic spiral" rate of (1/radius) increase in not constant, like the Euler spiral is, and its monotonic decrease in that rate leads to mismatches between the approximations for point/angle of intersection with the constant radius circle that can create significant angular "kinks" much past 10 degrees.  (That is what confused me when I was earlier unable to match the Bezier curves to the specs I was using for the cubic spirals.)

Applications for both the cubic spiral and Euler spiral start with user inputs for the length of the easement and the radius of the circular section to be joined.  Angles can then be calculated, based on the appropriate formulae for each type of curve.  But, both of those easement curves come out a lot longer than the easement curves produced by AnyRail when I compute the proper angle for my choice of length and radius, and then provide your program with that angle and my chosen radius.

So, the next step is to review how you choose the length for you Bezier curve for an easement. 


David

#10
I think you're overestimating my math skills!
I can read a math article, but I'm not capable of putting just any function into a cubic Bézier curve and prove it's close enough.

Also, as this is a forum, I'm always a bit reluctant to reply too quickly to any question. It's meant to be a discussion platform between users, not so much between a user and me.

In this case it's very likely that others are far more skilled in math than me, and you might have a discussion of much higher quality.


In AnyRail, there are two constraints:
- The easement should be defined as a cubic Bézier curve, so with 4 control points.
- It should approximate a planar spiral function as close as possible.

The article mentioned shows how to do that. We've left out the 'm' and 'q' parameters for our AnyRail users, as they're way too complex to explain. So as a result, we've implemented the planar cubic Bézier spiral as proposed by Walton and Meek, reference [11] in the article.

The length of the easement follows from that, it's not an input parameter.

Perhaps we could do better using higher order Bézier curves, but I think that's far beyond the purpose of AnyRail. We're planning a model railroad, not a high speed train track.

However, if anyone can come up with a better solution, with more control over the easement, using parameters that are easy to understand for anybody, I'll be happy to add it.

P.S. I do have a Model Railroader subscription, but the article you mention from 1969 is not available on line I guess?

David Hoogvorst. Founder and Owner of DRail Software. Creator of AnyRail.

Maletrain

OK David, let me go through the issues, one at a time

Quote[A]s this is a forum, ... t's meant to be a discussion platform between users, not so much between a user and me.
I understand.  That is why I started the thread in the forum, rather than just e-mailing you directly.  But, it seems that others are not participating. And, what I propose below will involve me sending you files that I can't post to the forum.  So, I think we should try to put some of the discussion on here, but just do the nitty-gritty math off-forum.



QuoteIn AnyRail, there are two constraints:
- The easement should be defined as a cubic Bézier curve, so with 4 control points.
- It should approximate a planar spiral function as close as possible.

Why does an easment have to be a Bezier curve?  I think your other sectional track pieces, switches and such are not Bezier curves.  Is that right? If so, would you be open to "making" an easement that is like a piece of sectional track, with no control points for later manipulation?  For an easement, I think that not being able to change its shape with control points makes more sense than the current situation.

QuoteThe article mentioned shows how to do that. We've left out the 'm' and 'q' parameters for our AnyRail users, as they're way too complex to explain. So as a result, we've implemented the planar cubic Bézier spiral as proposed by Walton and Meek, reference [11] in the article.

As before, when I Google for that article ypu cite, I get similar articles by the same authors, but not the exact one you used.  Still, I think I see where some of the problems occur.  Walton and Meek propose an easement curve with the first three control points on the same line as the straight section the easement joins, and with the angle (theta) between the third and fourth (end) control points, with the distance between the first and second control points equal to the distance between the second and third control points. Walton and Meek also reference work by Yeoh and Ali that adds another fitting parameter by letting the distance between the first and second control points not equal the distance between the second and third contol points, although the first 3 control points remain on the straight line that the easment starts from.  I have found that I can make reasonably good representations of the proper cubic spiral easement shape with the Yeoh and Ali technique.  I can send you some AnyRail files that demostrate that.

QuoteThe length of the easement follows from that, it's not an input parameter.

It would be helpful if you would just tell me how you calculate the length of the easement, because that is where the shape problem seems to arise.  From playing with the easement function in AnyRail, I think you automatically set the distance between contol points to all be equal, although Meek and Walton do not specify that the the distance between the third and fourth control points should equal the distances used between the first and second (which they set equal to the distance between the second and third).

QuotePerhaps we could do better using higher order Bézier curves, but I think that's far beyond the purpose of AnyRail. We're planning a model railroad, not a high speed train track.

A better easement shape is important to designing a model railroad, for 2 reasons: (1) to look realistic, the easement must start with imperceptible curvature and
progress with reasonably smoothly increasing curvature to the constant radius arc, and, more importantly, (2) the easements must minimize coupler offset between cars entering the short radius curves typically used by model railroaders so as to avoid derailments.  The most important parameter for the second function is the length of the easement, which is an input parameter for calculation of real easements, whether using the full Euler spiral or its approximation with a cubic spiral.  The current easement function in AnyRail tends to make much shorter easements than either the Euler of cubic spiral for the same angle of deflection.  That is why I started this thread.

QuoteHowever, if anyone can come up with a better solution, with more control over the easement, using parameters that are easy to understand for anybody, I'll be happy to add it.

I would like to work with you to do that.  I propose an easement function that uses either an Euler spiral or a cubic spiral, with user inputs of length and radius.  I can provide you with Excel spread sheets that calculate the shape and the angle of deflection, and even the center of the circular arc that the easement is connecting to the straight section.  That will allow you to see the math in an easy to copy form.  This would make layout planning more accurate, by giving proper lengths and offsets to the easements so that their effects on fitting the plan to the space available would match how those easements are eventually laid out on the train board. In addition, it would allow for full scale printing of the easement as a template to really simplify laying the real track when the time comes to bring a plan to reality.  I think that the back-and-forth discussing the options and implementation should probably best be done off-form, by direct e-mail.  We can update this thread with major milestones or questions for users as we proceed off-forum.

QuoteP.S. I do have a Model Railroader subscription, but the article you mention from 1969 is not available on line I guess?

I tried to find the issue on-line, but could not.  However, I have noted that the templates that were provided in the article do not fully match the mathematics stated in the article.   Apparently, the templates actually used Euler spirals, but the text gave the logic for the cubid spiral approximation.  This mis-match becomes apparent when one notes that a cubic spiral has a minimum radius that is larger than some of the radii shown on the templates.  So, I really cannot recommend that article as a basis for improving the AnyRail easement function.  But, if you like, I could mail you a paper copy of the article, anyway.  I did find useful articles on both the cubic and Euler spirals that I can provide by link or simply attaching copies to e-mails.

Let me know how you want to proceed.

BritsTukker

Since you want other users to join in, I will.

I have been using the Anyrail easements for a number of years. They give a significant improvement  to the smooth running of stock compared to using the non-flex 'settrack' types of track, especially if you super-elevate the outer rail of the curves. I suspect that adding the super-elevation improves the look and running properties more than any additional mathematical improvement will.

I am neither a theorist nor a stickler for 'prototypicality' and I find the present solution perfectly adequate for my purposes.

chaz

Every year or so, someone (me at first) has requested a tool similar to "Smooth Flex" except it would create eased connections to whatever the flex track was connected to. I wanted to use the LaGrange Polynomial Approximation (one of many that would work) to create the mathematical function. The problem was that once we had the polynomial exponents, we could not find a way to convert them to Bezier control point positions.

After the initial discussions in this forum, David and I took the detailed conversations off-line. I think I gave him headaches, but he always took the time to respond.

In the end, the demand for this feature was very low because most people (me included) were happy with the existing AR features.

I find that the resulting easements are very reasonable if I keep the angle within 5 and 15 degrees.
MP 525.25 on the Prosser Subdivision of the North Kansas Division of the MOPAC Railroad.

Maletrain

Chaz,

In David's absense, can you tell me more about why there is a need to convert everything to Bezier control points?  Are the sectional track switches actually done with Bezier control points that we are not shown?  Or, are they rigid shapes, with defined relative positions and relative angles on their connection points? It seems to me that a rigid easement would not be any harder to treat than a switch or other piece of sectional track.  Just think of it as a switch that doesn't have a straight path.

I agree that the currrent eaasement shapes look OK when the easements are kept between 5 and at least 10 degrees, but that makes the easements too short for minimizing coupler mismatch.  Making the easements as long as I want them requires larger angles, and starts to make odd shapes.

At least, I would like to have a function that allows me to independentlyspecify length of easement and radius to be connected, because those are the variables that are used to design a model railroad to reliably run equipment of chosen lengths over track fit into a limited space with a chosen minimum radius for curves. The current easement feature requires me to chose an angle, instead of calculate it from length and radius, and then measure the results with a "ruler" on the screen, then iterate on the angle parameter to get the length I need.

If David is stuck with using Bezier curves, I can at least show him how to make a Bezier curve fit a cubic "spiral" shape within the first 15 degrees, with the cubic specified in terms of length and radius and having the y = x^3/(6RL) shape that railroads actually use. 

If he can go with rigid shapes, it would be better to use the actual Euler spiral, because the cubic "spiral" breaks down at angles that some users have been talking about using for easements in this forum. When the cubic spirals no longer closely match the "rules-of-thumb", it creates either a mismatch of radius or alignment where the easement joins the constant-radius curve, which can cause issues with running trains, if not corrected when the track is laid, or it requires  changes to the plan to correct.  Because easements are a significant factor in planning what will fit into a given space, I think it is best to get them done as well as possible at the panning stage.

And, if AnyRail can show the proper shape for a Euler spiral easement, then it could be printed 1:1 and used as a template to actually lay the track.  I think that would be a big plus for marketing the program.