Calculate Geometry NURBSTo row values from Points in Scratch

Started by RailwayKen, August 23, 2024, 02:35:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RailwayKen

Obviously this solution could further be improved by putting the points by ElipticalArcTo rows.

I suppose the SplineStart and SplineKnot rowtypes may be worth looking into also-- though that might get me back to NURBS complexity. (I have not looked into these rowtypes yet.)

It's also not necessary to have all the points be equidistant. When I return to this in a few days, I may try having the last point and next-to-last points be quite close together, as this may be all that is necessary to make the ANGLEALONGPATH accurate enough. Guessing I may need to find a "very close but not too close" separation distance for these points to avoid rounding/floating point error issues.

Yacine

I don't know if you noticed, but the parent shape has one central cell that governs the angle formula of all its sub-shapes. This is very convenient for experimenting with the formula. I'm telling this because you mentioned different calculation methods.

And you don't need python. I just used it to connect the segments.

And if you drop the python code into an AI and ask kindly to convert it to VBA, I'm sure you'll get what you want.
Yacine

wapperdude

I've been pursuing an alternative approach, using circles and ElipitalArcTo shapesheet functions.  In theory, rather simple concept.  In practice, depending upon the "strictness" of accuracy, not that trivial to implement.  This is still a work in progress...  I present it as a teaser, should someone either be interested or want to pursue on their own.

Interestingly, it is scalable.  So smaller units, of two, or three pieces, could be cascaded to make longer, more involved spirals.  Indeed, by changing the segment size, the incremental sizing of the radii, many different types of spirals might be constructed.

The attached file uses 1/4 circular segments (90 deg) with radii decreasing buy 1/2.  If I'm not mistaken, this would be forming an Archimedes spiral. 
Visio 2019 Pro

Yacine

@RailwayKen, I wonder if and how we can be of any further help.
I've seen your posts and your explanations, but I cannot clearly see any clear requests or questions.
Yacine

wapperdude

Well, here's update to my file to bring it to a potentially meaningful closing point.  The file has 4 pages.
First page details the process for doing a manual creation.  For the example, the radii for each circle is 1/2 previous circle, and the enclosed angle is 90 degrees.  However, both the angle and radii may be any chosen value, and are independent of each other.  Directions are on the page.

2nd page is similar to first, except the process has been captured in VBA macros.  The process mimics page 1 method, but shapesheet results are different, there being 3 geometry sections as opposed to 1. 

Pages 3 and 4 look at scalability.
Page 3 shows the process of rescaling and the subsequent preservation of all shape relationships.  This means that complex spirals may be easily formed from simple structures.

Page 4 briefly looks at this complex from simple.
Visio 2019 Pro

RailwayKen

Quote from: Yacine on August 27, 2024, 09:04:45 PM@RailwayKen, I wonder if and how we can be of any further help.
I've seen your posts and your explanations, but I cannot clearly see any clear requests or questions.

Original question is now buried early in the thread. I had written: "How does one calculate the values for knot1, knot2, ... knotLast?" which in context was meant to say, "How do you calculate knot1, knot2,... knotLast NURBSTo row values when given an array of X,Y coordinates for a particular spiral that are calculated in the Scratch cells?"

I think Nikolay's humorous response about sums it up: What I am trying to do is quite complicated so perhaps try a different approach.

You (Yacine) provided an idea. While I did not use your architecture, I did use your concept of simply connecting the points with something simpler than a NURBS. At this point, I probably have no further questions on this topic (unless some math genius is lurking who really had better to do than to teach me the math behind NURBS!).

wapperdude expressed interest in how I solved this. So I posted a bit more.

Thanks everyone for your time. I've been lurking on this forum for some time and for the most part haven't found a new question until this one. I am honored and humbled at all the work some of you went through.

RailwayKen

Quote from: wapperdude on August 29, 2024, 12:50:20 AMWell, here's update to my file to bring it to a potentially meaningful closing point.

I am trying for a specific spiral matching very specific formulas (which are contained, in a manner, in the Scratch cells of a file I posted earlier). You appear to have made a different spiral, which is interesting.

To perhaps close this thread out, my final solution plots X,Y coordinates in the Scratch cells, and then connects them with LineTo segments in the Geometry1 section of the shape sheet. I used code to create the Scratch and Geometry cells, with a CALLTHIS function on the ShapeSheet to re-run the code if the user changes a value. I'll likely do some further refinements, but none of these have any questions for the forum at this time. Thanks all again.

wapperdude

QuoteYou appear to have made a different spiral, which is interesting.

The spiral that was done was a demo choice.  The goal was to use a graphic approach to obtain a quick solution.  The parameters chosen show very quickly that a spiral has been generated.  But, there would actually be infinite number of possibilities by merely changing the radius and or the segment angle.
Visio 2019 Pro

wapperdude

Hmmmm.  I had missed that you posted sample Visio file.  Took a look at it.  Must admit, I was surprised.  Not what I expected.  I placed a circle over your curve plot, well, actually, behind it.  There seems to be very little deviation from an actual circle.  Am I missing something?  Based upon what your calculated curve does, why bother?

...Add edit...
Let me elaborate.   Based upon some of the spiral descriptions, Lionel O-gauge products, and the course of this post,  my expectations were to use a spiral transition to migrate from a rather large radius curve to a fairly tight, short radius.curve.  In O-gauge, say a 72" diameter down to a 48" diameter, with the spiral arc encompassing a 180° arc total enclosed angle.  I guess my expectations spiralled unreasonably, eh???  🤔😄😉
Visio 2019 Pro

RailwayKen

Below is far afield from a Visio forum. Maybe message me if more is desired than is properly placed here. That said, to answer the esteemed Wapperdude's question:

The below picture has radius = 250 feet and length of spiral = 170 feet.
You cannot view this attachment.
The "offset" distance shown is only about 5 ft. In HO scale this is only 0.69 inches or 17.5 mm. Small indeed.

The reason a real railroad uses spirals is avoid an instantaneous change in angular velocity of the wheelsets (that is, the "trucks" or "bogies" depending on where you live.) If a bogie transitioned from tangent track directly to circular track, the angular (rotational) acceleration would be theoretically infinite. Even with the much bigger radii a real railroad uses on main tracks, lack of a spiral creates a lurch (increased risk of shifting load), high forces at the rail-wheel interface, lower safe operating speed, and increases maintenance cost. In the 1800s as velocity increased, the railroads observed that if they did not put in some kind of a spiral, the track would shift by itself to create one.

For a model railroad, with our much tighter curves (and shorter spirals), increased car overhang and coupler mismatch entering the curve are the bigger problems. For example, a long car can pull a short car off the track. Also, the lurch on looks unrealistic. (Consider how a Lionel toy train looks entering a circular curve vs. what a real train looks like.) So, modelers looking for more realistic appearance generally use some kind of an easement. Incidentally, there are MUCH easier ways to construct a good enough easement than what I am doing.

For a more extensive look at why a model railroad might use an "easement" curve (and for a less mathematically intense way to construct one!), I strongly recommend Track Planning for Realistic Operations, John Armstrong ((c) 1979 Milwaukee: Kalmbach Pub. Co.). See pp. 44-45. An electronic copy for electronic loan is available at https://archive.org. If you are actually building a model railroad, newer editions can still be purchased. (I am not affiliated with the publisher.)

wapperdude

Thanks.  Understood.  Yes.  Agree let this portion of public discussion rest.

Happy tracks to you! 
Visio 2019 Pro

RailwayKen

I'll add one more post to this, as it might actually relate to how you would edit the shape. But yes, feel free to message me.

Quote from: wapperdude on August 31, 2024, 01:23:49 AM...Add edit...
Let me elaborate.  Based upon some of the spiral descriptions, Lionel O-gauge products, and the course of this post,  my expectations were to use a spiral transition to migrate from a rather large radius curve to a fairly tight, short radius.curve.  In O-gauge, say a 72" diameter down to a 48" diameter, with the spiral arc encompassing a 180° arc total enclosed angle.  I guess my expectations spiralled unreasonably, eh???  🤔😄😉

The formulas in my shape require working in scale units. I have the scale of the Viso page set to 3.5 mm = 1 ft.
72" and 48" in O scale = 288 and 192 scale feet respectively (using O scale is 1:48).

Perfectly reasonable to adapt my shape into a curve that would connect a 288 ft circular arc to a 192 ft circular arc.

The Talbot spiral is defined such that the degree of curve increases linearly along the length of the spiral. The formula that relates degree of curve to radius is easy to find. (U.S. railroads primarily use the chord definition. The arc definition is slightly different.)

A crude, but workable way to do this would be to define a spiral of appropriately long Ls with radius 192 feet. Then find the point on the spiral where the radius = 288 ft. Then delete all the Geometry1 rows for the portion where instantaneous radius > 288 ft.


Yacine

Just tinkering around for fun.

Used beautifulsoup4 to collect the content of this page.
Dropped this content into Claude.ai and asked it to analyse the thread. got some blabla.
Asked it then what really matters in the railroad design and it answered:

1. Key Parameters for Minimizing Lateral Forces:

  a) Rate of change of curvature: This is crucial. A smooth, gradual increase in curvature reduces sudden lateral forces.
 
  b) Entry and exit velocities: While not directly a curve parameter, this affects design choices.
 
  c) Total angle of direction change: As you mentioned, the overall change in direction.
 
  d) Available distance: The space available for the transition.

2. Useful Design Parameters:

  a) Total angle of direction change (θ): As you suggested, this is a key input.
 
  b) Design speed (V): This influences the rate of curvature change needed.
 
  c) Final radius of curvature (R): This determines the sharpness of the main circular curve.
 
  d) Length of spiral transition (L): This affects how gradual the transition is.
 
  e) Starting and ending curvature: Usually 0 (straight) at the start, and 1/R at the end.

3. Derived Parameters:

  a) Clothoid parameter (A): Where A^2 = R * L. This single value encapsulates the "smoothness" of the transition.
 
  b) Rate of curvature change: Usually kept constant along the spiral.

4. Practical Considerations:

  a) Superelevation (banking) transition: This often coincides with the spiral transition.
 
  b) Clearance requirements: Affects the offset from the original tangent line.

5. Potential User Inputs:

  a) Entry point coordinates
  b) Initial direction
  c) Final direction (or total angle change)
  d) Design speed
  e) Either final radius OR length of spiral (the other can be calculated)
  f) Optional: maximum lateral acceleration allowed

From these inputs, a system could calculate the optimal spiral transition and circular arc, providing outputs like:

- Spiral length
- Circular arc length
- Total curve length
- Maximum offset from tangent
- Coordinates of key points (spiral start, spiral-circle transition, curve end)
- Curvature at any point along the transition

This approach would allow for flexible, intuitive design while ensuring the resulting curve minimizes lateral forces within the given constraints.
Yacine

Yacine

YG
The train will then run in some straight direction. I guess that what you defined the end of the curve, should actually be the middle. As from the max curvature, we'll need to come back to 0?

You're absolutely correct, and I apologize for not making that clear in my previous response. You've highlighted a crucial aspect of the complete curve design. Let's refine our understanding:

1. Complete Curve Structure:
   - Entry spiral (from straight to max curvature)
   - Constant radius curve (maintaining max curvature)
   - Exit spiral (from max curvature back to straight)

2. Symmetry:
   - In most cases, the entry and exit spirals are symmetrical
   - The point of maximum curvature is indeed in the middle of the entire curve structure

3. Revised Parameters:
   a) Total angle of direction change (θ): Now refers to the entire curve
   b) Length of constant radius section (Lc)
   c) Length of each spiral transition (Ls)
   d) Total curve length: 2Ls + Lc

4. Design Considerations:
   - The constant radius section can be very short or even non-existent in some designs, resulting in a continuous spiral from straight to straight
   - In practice, having some constant radius section often simplifies construction and maintenance

5. User Inputs Refinement:
   a) Entry point coordinates
   b) Initial direction
   c) Final direction (total angle change)
   d) Design speed
   e) Minimum radius (at the point of maximum curvature)
   f) Either spiral length OR rate of curvature change
   g) Optional: desired length of constant radius section

6. Outputs:
   - Spiral entry length
   - Constant radius section length
   - Spiral exit length
   - Total curve length
   - Coordinates of key points:
     * Spiral entry start
     * Entry spiral to constant radius transition
     * Constant radius to exit spiral transition
     * Spiral exit end
   - Curvature and superelevation at any point along the entire curve

This revised approach ensures a complete, symmetrical curve design that starts from a straight section, transitions to a maximum curvature, maintains that curvature for a desired length, and then transitions back to a straight section. This design minimizes lateral forces at both entry and exit, providing a smooth ride throughout the entire curve.
Yacine

Yacine

As a passenger I would feel a constant or a an increasing acceleration - force pulling me outside?


You're right to consider the passenger experience. Let's break this down:

1. In a perfectly designed curve:

  - Entry spiral: You'd feel gradually increasing lateral force pulling you outward.
  - Constant radius section: You'd feel a constant lateral force.
  - Exit spiral: You'd feel gradually decreasing lateral force.

2. The sensation of force:
 
  - The rate of change of acceleration (jerk) is what humans typically notice most.
  - In the spiral sections, the change is gradual, so it feels smoother.
  - In the constant radius section, the force is steady, which can feel more noticeable once it's not changing.

3. Factors affecting perception:

  - Speed: Higher speeds increase the lateral force.
  - Superelevation (banking): Reduces the perceived lateral force.
  - Vehicle suspension: Can dampen the forces felt inside.

4. Ideal vs. Reality:

  - Theoretically, a continuously varying spiral could feel smoothest.
  - In practice, a well-designed curve with spirals and a constant section is usually very comfortable.

5. Design considerations:

  - Longer spirals generally feel smoother but take up more space.
  - The constant section allows for a period of stable forces, which can be beneficial for longer curves.

So, you're correct that you'd feel an increasing force in the entry spiral. In a well-designed curve, this increase should be gradual enough to be comfortable. The constant force in the middle section might become more noticeable simply because it's not changing, rather than because it's stronger.
Yacine

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 421 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1290KB.
Tokens: post-login.
Cache hits: 15: 0.00157s for 26,548 bytes (show)
Cache misses: 5: (show)
Queries used: 17.

[Show Queries]